chore: repo sync

This commit is contained in:
Hackntosh 2024-02-01 18:10:22 +00:00
parent 78471ba5c4
commit cf101674e7
7 changed files with 43 additions and 56 deletions

View file

@ -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) {}

View file

@ -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();
});
});

View file

@ -6,12 +6,21 @@ import {
Patch,
Param,
Delete,
UseInterceptors,
UploadedFiles,
Request,
} from "@nestjs/common";
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 { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger";
import {
ApiBearerAuth,
ApiConsumes,
ApiOperation,
ApiTags,
} from "@nestjs/swagger";
import { Public } from "src/public.decorator";
import { FilesInterceptor } from "@nest-lab/fastify-multer";
@ApiTags("Kweeks")
@Controller("kweeks")
@ -21,7 +30,13 @@ export class KweeksController {
@Post()
@ApiOperation({ summary: "Creates a kweek" })
@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);
}

View file

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common';
import { KweeksService } from './kweeks.service';
import { KweeksController } from './kweeks.controller';
import { Module } from "@nestjs/common";
import { KweeksService } from "./kweeks.service";
import { KweeksController } from "./kweeks.controller";
import { PrismaModule } from "src/prisma/prisma.module";
@Module({
imports: [PrismaModule],
controllers: [KweeksController],
providers: [KweeksService],
})

View file

@ -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();
});
});

View file

@ -1,15 +1,13 @@
import { Injectable } from '@nestjs/common';
import { CreateKweekDto } from './dto/create-kweek.dto';
import { UpdateKweekDto } from './dto/update-kweek.dto';
import { Injectable } from "@nestjs/common";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto";
import { PrismaService } from "src/prisma/prisma.service";
@Injectable()
export class KweeksService {
create(createKweekDto: CreateKweekDto) {
return 'This action adds a new kweek';
}
findAll() {
return `This action returns all kweeks`;
constructor(private readonly prisma: PrismaService) {}
create(createKweekDto: CreateKweekDTO) {
return "This action adds a new kweek";
}
findOne(id: number) {

View file

@ -14,8 +14,8 @@ import { S3Service } from "./s3.service";
@Injectable()
export class UserService {
constructor(
private prisma: PrismaService,
private s3: S3Service,
private readonly prisma: PrismaService,
private readonly s3: S3Service,
) {}
async auth_search(username: string): Promise<UserModel> {
const user = await this.prisma.user.findFirst({