mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
chore: repo sync
This commit is contained in:
parent
78471ba5c4
commit
cf101674e7
7 changed files with 43 additions and 56 deletions
|
@ -1 +1,11 @@
|
||||||
export class CreateKweekDto {}
|
import { createZodDto } from "nestjs-zod";
|
||||||
|
import { z } from "nestjs-zod/z";
|
||||||
|
|
||||||
|
export const CreateKweekSchema = z
|
||||||
|
.object({
|
||||||
|
content: z.string({ required_error: "Kweek content is required" }).max(300),
|
||||||
|
files: z.array(z.object({})),
|
||||||
|
})
|
||||||
|
.required();
|
||||||
|
|
||||||
|
export class CreateKweekDTO extends createZodDto(CreateKweekSchema) {}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { KweeksController } from './kweeks.controller';
|
|
||||||
import { KweeksService } from './kweeks.service';
|
|
||||||
|
|
||||||
describe('KweeksController', () => {
|
|
||||||
let controller: KweeksController;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
controllers: [KweeksController],
|
|
||||||
providers: [KweeksService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
controller = module.get<KweeksController>(KweeksController);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(controller).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -6,12 +6,21 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Param,
|
Param,
|
||||||
Delete,
|
Delete,
|
||||||
|
UseInterceptors,
|
||||||
|
UploadedFiles,
|
||||||
|
Request,
|
||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
import { KweeksService } from "./kweeks.service";
|
import { KweeksService } from "./kweeks.service";
|
||||||
import { CreateKweekDto } from "./dto/create-kweek.dto";
|
import { CreateKweekDTO } from "./dto/create-kweek.dto";
|
||||||
import { UpdateKweekDto } from "./dto/update-kweek.dto";
|
import { UpdateKweekDto } from "./dto/update-kweek.dto";
|
||||||
import { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger";
|
import {
|
||||||
|
ApiBearerAuth,
|
||||||
|
ApiConsumes,
|
||||||
|
ApiOperation,
|
||||||
|
ApiTags,
|
||||||
|
} from "@nestjs/swagger";
|
||||||
import { Public } from "src/public.decorator";
|
import { Public } from "src/public.decorator";
|
||||||
|
import { FilesInterceptor } from "@nest-lab/fastify-multer";
|
||||||
|
|
||||||
@ApiTags("Kweeks")
|
@ApiTags("Kweeks")
|
||||||
@Controller("kweeks")
|
@Controller("kweeks")
|
||||||
|
@ -21,7 +30,13 @@ export class KweeksController {
|
||||||
@Post()
|
@Post()
|
||||||
@ApiOperation({ summary: "Creates a kweek" })
|
@ApiOperation({ summary: "Creates a kweek" })
|
||||||
@ApiBearerAuth("JWT")
|
@ApiBearerAuth("JWT")
|
||||||
create(@Body() createKweekDto: CreateKweekDto) {
|
@ApiConsumes("multipart/form-data")
|
||||||
|
@UseInterceptors(FilesInterceptor("attachments", 4))
|
||||||
|
create(
|
||||||
|
@Body() createKweekDto: CreateKweekDTO,
|
||||||
|
@UploadedFiles() attachments: File,
|
||||||
|
@Request() req,
|
||||||
|
) {
|
||||||
return this.kweeksService.create(createKweekDto);
|
return this.kweeksService.create(createKweekDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from "@nestjs/common";
|
||||||
import { KweeksService } from './kweeks.service';
|
import { KweeksService } from "./kweeks.service";
|
||||||
import { KweeksController } from './kweeks.controller';
|
import { KweeksController } from "./kweeks.controller";
|
||||||
|
import { PrismaModule } from "src/prisma/prisma.module";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
imports: [PrismaModule],
|
||||||
controllers: [KweeksController],
|
controllers: [KweeksController],
|
||||||
providers: [KweeksService],
|
providers: [KweeksService],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { KweeksService } from './kweeks.service';
|
|
||||||
|
|
||||||
describe('KweeksService', () => {
|
|
||||||
let service: KweeksService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
providers: [KweeksService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<KweeksService>(KweeksService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,15 +1,13 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from "@nestjs/common";
|
||||||
import { CreateKweekDto } from './dto/create-kweek.dto';
|
import { CreateKweekDTO } from "./dto/create-kweek.dto";
|
||||||
import { UpdateKweekDto } from './dto/update-kweek.dto';
|
import { UpdateKweekDto } from "./dto/update-kweek.dto";
|
||||||
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class KweeksService {
|
export class KweeksService {
|
||||||
create(createKweekDto: CreateKweekDto) {
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
return 'This action adds a new kweek';
|
create(createKweekDto: CreateKweekDTO) {
|
||||||
}
|
return "This action adds a new kweek";
|
||||||
|
|
||||||
findAll() {
|
|
||||||
return `This action returns all kweeks`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(id: number) {
|
findOne(id: number) {
|
||||||
|
|
|
@ -14,8 +14,8 @@ import { S3Service } from "./s3.service";
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
constructor(
|
constructor(
|
||||||
private prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private s3: S3Service,
|
private readonly s3: S3Service,
|
||||||
) {}
|
) {}
|
||||||
async auth_search(username: string): Promise<UserModel> {
|
async auth_search(username: string): Promise<UserModel> {
|
||||||
const user = await this.prisma.user.findFirst({
|
const user = await this.prisma.user.findFirst({
|
||||||
|
|
Loading…
Reference in a new issue