mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-10-25 11:57:56 +00:00
feat: add validation for documents
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { Body, Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
|
||||
import { Body, Controller, Post, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
||||
import { memoryStorage } from 'multer';
|
||||
import { IJwtPayload } from '~/auth/interfaces';
|
||||
import { AuthenticatedUser } from '~/common/decorators';
|
||||
import { AccessTokenGuard } from '~/common/guards';
|
||||
import { ResponseFactory } from '~/core/utils';
|
||||
import { UploadDocumentRequestDto } from '../dtos/request';
|
||||
import { DocumentMetaResponseDto } from '../dtos/response';
|
||||
@@ -9,6 +12,8 @@ import { DocumentType } from '../enums';
|
||||
import { DocumentService } from '../services';
|
||||
@Controller('document')
|
||||
@ApiTags('Document')
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AccessTokenGuard)
|
||||
export class DocumentController {
|
||||
constructor(private readonly documentService: DocumentService) {}
|
||||
|
||||
@@ -36,8 +41,9 @@ export class DocumentController {
|
||||
async createDocument(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body() uploadedDocumentRequest: UploadDocumentRequestDto,
|
||||
@AuthenticatedUser() user: IJwtPayload,
|
||||
) {
|
||||
const document = await this.documentService.createDocument(file, uploadedDocumentRequest);
|
||||
const document = await this.documentService.createDocument(file, uploadedDocumentRequest, user.sub);
|
||||
|
||||
return ResponseFactory.data(new DocumentMetaResponseDto(document));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user