refactor: global validation pipe (#7985)

* refactor: global validation pipe

* chore: formatting
This commit is contained in:
Jason Rasmussen 2024-03-15 12:51:08 -04:00 committed by GitHub
parent 5a6b71dda3
commit 2a0e1c0d3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 14 additions and 74 deletions

View File

@ -13,7 +13,6 @@ import {
Res, Res,
UploadedFiles, UploadedFiles,
UseInterceptors, UseInterceptors,
ValidationPipe,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBody, ApiConsumes, ApiHeader, ApiTags } from '@nestjs/swagger'; import { ApiBody, ApiConsumes, ApiHeader, ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express'; import { NextFunction, Response } from 'express';
@ -58,7 +57,7 @@ export class AssetController {
async uploadFile( async uploadFile(
@Auth() auth: AuthDto, @Auth() auth: AuthDto,
@UploadedFiles(new ParseFilePipe({ validators: [new FileNotEmptyValidator(['assetData'])] })) files: UploadFiles, @UploadedFiles(new ParseFilePipe({ validators: [new FileNotEmptyValidator(['assetData'])] })) files: UploadFiles,
@Body(new ValidationPipe({ transform: true })) dto: CreateAssetDto, @Body() dto: CreateAssetDto,
@Res({ passthrough: true }) res: Response, @Res({ passthrough: true }) res: Response,
): Promise<AssetFileUploadResponseDto> { ): Promise<AssetFileUploadResponseDto> {
const file = mapToUploadFile(files.assetData[0]); const file = mapToUploadFile(files.assetData[0]);
@ -90,7 +89,7 @@ export class AssetController {
@Next() next: NextFunction, @Next() next: NextFunction,
@Auth() auth: AuthDto, @Auth() auth: AuthDto,
@Param() { id }: UUIDParamDto, @Param() { id }: UUIDParamDto,
@Query(new ValidationPipe({ transform: true })) dto: ServeFileDto, @Query() dto: ServeFileDto,
) { ) {
await sendFile(res, next, () => this.serviceV1.serveFile(auth, id, dto)); await sendFile(res, next, () => this.serviceV1.serveFile(auth, id, dto));
} }
@ -103,7 +102,7 @@ export class AssetController {
@Next() next: NextFunction, @Next() next: NextFunction,
@Auth() auth: AuthDto, @Auth() auth: AuthDto,
@Param() { id }: UUIDParamDto, @Param() { id }: UUIDParamDto,
@Query(new ValidationPipe({ transform: true })) dto: GetAssetThumbnailDto, @Query() dto: GetAssetThumbnailDto,
) { ) {
await sendFile(res, next, () => this.serviceV1.serveThumbnail(auth, id, dto)); await sendFile(res, next, () => this.serviceV1.serveThumbnail(auth, id, dto));
} }
@ -133,10 +132,7 @@ export class AssetController {
required: false, required: false,
schema: { type: 'string' }, schema: { type: 'string' },
}) })
getAllAssets( getAllAssets(@Auth() auth: AuthDto, @Query() dto: AssetSearchDto): Promise<AssetResponseDto[]> {
@Auth() auth: AuthDto,
@Query(new ValidationPipe({ transform: true })) dto: AssetSearchDto,
): Promise<AssetResponseDto[]> {
return this.serviceV1.getAllAssets(auth, dto); return this.serviceV1.getAllAssets(auth, dto);
} }
@ -147,7 +143,7 @@ export class AssetController {
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
checkExistingAssets( checkExistingAssets(
@Auth() auth: AuthDto, @Auth() auth: AuthDto,
@Body(ValidationPipe) dto: CheckExistingAssetsDto, @Body() dto: CheckExistingAssetsDto,
): Promise<CheckExistingAssetsResponseDto> { ): Promise<CheckExistingAssetsResponseDto> {
return this.serviceV1.checkExistingAssets(auth, dto); return this.serviceV1.checkExistingAssets(auth, dto);
} }
@ -159,7 +155,7 @@ export class AssetController {
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
checkBulkUpload( checkBulkUpload(
@Auth() auth: AuthDto, @Auth() auth: AuthDto,
@Body(ValidationPipe) dto: AssetBulkUploadCheckDto, @Body() dto: AssetBulkUploadCheckDto,
): Promise<AssetBulkUploadCheckResponseDto> { ): Promise<AssetBulkUploadCheckResponseDto> {
return this.serviceV1.bulkUploadCheck(auth, dto); return this.serviceV1.bulkUploadCheck(auth, dto);
} }

View File

@ -1,8 +1,8 @@
import { DomainModule } from '@app/domain'; import { DomainModule } from '@app/domain';
import { InfraModule } from '@app/infra'; import { InfraModule } from '@app/infra';
import { AssetEntity, ExifEntity } from '@app/infra/entities'; import { AssetEntity, ExifEntity } from '@app/infra/entities';
import { Module, OnModuleInit } from '@nestjs/common'; import { Module, OnModuleInit, ValidationPipe } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'; import { APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
import { ScheduleModule } from '@nestjs/schedule'; import { ScheduleModule } from '@nestjs/schedule';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { AssetRepositoryV1, IAssetRepositoryV1 } from './api-v1/asset/asset-repository'; import { AssetRepositoryV1, IAssetRepositoryV1 } from './api-v1/asset/asset-repository';
@ -70,6 +70,7 @@ import { ErrorInterceptor, FileUploadInterceptor } from './interceptors';
PersonController, PersonController,
], ],
providers: [ providers: [
{ provide: APP_PIPE, useValue: new ValidationPipe({ transform: true, whitelist: true }) },
{ provide: APP_INTERCEPTOR, useClass: ErrorInterceptor }, { provide: APP_INTERCEPTOR, useClass: ErrorInterceptor },
{ provide: APP_GUARD, useClass: AppGuard }, { provide: APP_GUARD, useClass: AppGuard },
{ provide: IAssetRepositoryV1, useClass: AssetRepositoryV1 }, { provide: IAssetRepositoryV1, useClass: AssetRepositoryV1 },

View File

@ -17,28 +17,15 @@ import {
SwaggerDocumentOptions, SwaggerDocumentOptions,
SwaggerModule, SwaggerModule,
} from '@nestjs/swagger'; } from '@nestjs/swagger';
import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
import { NextFunction, Response } from 'express'; import { NextFunction, Response } from 'express';
import _ from 'lodash'; import _ from 'lodash';
import { writeFileSync } from 'node:fs'; import { writeFileSync } from 'node:fs';
import { access, constants } from 'node:fs/promises'; import { access, constants } from 'node:fs/promises';
import path, { isAbsolute } from 'node:path'; import path, { isAbsolute } from 'node:path';
import { promisify } from 'node:util'; import { promisify } from 'node:util';
import { applyDecorators, UsePipes, ValidationPipe } from '@nestjs/common';
import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
import { Metadata } from './app.guard'; import { Metadata } from './app.guard';
export function UseValidation() {
return applyDecorators(
UsePipes(
new ValidationPipe({
transform: true,
whitelist: true,
}),
),
);
}
type SendFile = Parameters<Response['sendFile']>; type SendFile = Parameters<Response['sendFile']>;
type SendFileOptions = SendFile[1]; type SendFileOptions = SendFile[1];

View File

@ -11,13 +11,11 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Query
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Response } from 'express'; import { Response } from 'express';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Activity') @ApiTags('Activity')
@Controller('activity') @Controller('activity')
@Authenticated() @Authenticated()
@UseValidation()
export class ActivityController { export class ActivityController {
constructor(private service: ActivityService) {} constructor(private service: ActivityService) {}

View File

@ -15,13 +15,11 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { ParseMeUUIDPipe } from '../api-v1/validation/parse-me-uuid-pipe'; import { ParseMeUUIDPipe } from '../api-v1/validation/parse-me-uuid-pipe';
import { Auth, Authenticated, SharedLinkRoute } from '../app.guard'; import { Auth, Authenticated, SharedLinkRoute } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Album') @ApiTags('Album')
@Controller('album') @Controller('album')
@Authenticated() @Authenticated()
@UseValidation()
export class AlbumController { export class AlbumController {
constructor(private service: AlbumService) {} constructor(private service: AlbumService) {}

View File

@ -9,13 +9,11 @@ import {
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'; import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('API Key') @ApiTags('API Key')
@Controller('api-key') @Controller('api-key')
@Authenticated() @Authenticated()
@UseValidation()
export class APIKeyController { export class APIKeyController {
constructor(private service: APIKeyService) {} constructor(private service: APIKeyService) {}

View File

@ -8,7 +8,6 @@ import {
AssetStatsResponseDto, AssetStatsResponseDto,
AuthDto, AuthDto,
DeviceIdDto, DeviceIdDto,
DownloadService,
MapMarkerDto, MapMarkerDto,
MapMarkerResponseDto, MapMarkerResponseDto,
MemoryLaneDto, MemoryLaneDto,
@ -19,21 +18,18 @@ import {
TimeBucketAssetDto, TimeBucketAssetDto,
TimeBucketDto, TimeBucketDto,
TimeBucketResponseDto, TimeBucketResponseDto,
TrashService,
UpdateAssetDto as UpdateDto, UpdateAssetDto as UpdateDto,
UpdateStackParentDto, UpdateStackParentDto,
} from '@app/domain'; } from '@app/domain';
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated, SharedLinkRoute } from '../app.guard'; import { Auth, Authenticated, SharedLinkRoute } from '../app.guard';
import { UseValidation } from '../app.utils';
import { Route } from '../interceptors'; import { Route } from '../interceptors';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Asset') @ApiTags('Asset')
@Controller('assets') @Controller('assets')
@Authenticated() @Authenticated()
@UseValidation()
export class AssetsController { export class AssetsController {
constructor(private searchService: SearchService) {} constructor(private searchService: SearchService) {}
@ -50,13 +46,8 @@ export class AssetsController {
@ApiTags('Asset') @ApiTags('Asset')
@Controller(Route.ASSET) @Controller(Route.ASSET)
@Authenticated() @Authenticated()
@UseValidation()
export class AssetController { export class AssetController {
constructor( constructor(private service: AssetService) {}
private service: AssetService,
private downloadService: DownloadService,
private trashService: TrashService,
) {}
@Get('map-marker') @Get('map-marker')
getMapMarkers(@Auth() auth: AuthDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> { getMapMarkers(@Auth() auth: AuthDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {

View File

@ -11,12 +11,10 @@ import {
import { Body, Controller, Get, Post, Query } from '@nestjs/common'; import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { AdminRoute, Auth, Authenticated } from '../app.guard'; import { AdminRoute, Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('Audit') @ApiTags('Audit')
@Controller('audit') @Controller('audit')
@Authenticated() @Authenticated()
@UseValidation()
export class AuditController { export class AuditController {
constructor(private service: AuditService) {} constructor(private service: AuditService) {}

View File

@ -19,13 +19,11 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Req,
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { Auth, Authenticated, GetLoginDetails, PublicRoute } from '../app.guard'; import { Auth, Authenticated, GetLoginDetails, PublicRoute } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Authentication') @ApiTags('Authentication')
@Controller('auth') @Controller('auth')
@Authenticated() @Authenticated()
@UseValidation()
export class AuthController { export class AuthController {
constructor(private service: AuthService) {} constructor(private service: AuthService) {}

View File

@ -3,13 +3,12 @@ import { Body, Controller, HttpCode, HttpStatus, Next, Param, Post, Res, Streama
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express'; import { NextFunction, Response } from 'express';
import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../app.guard'; import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../app.guard';
import { UseValidation, asStreamableFile, sendFile } from '../app.utils'; import { asStreamableFile, sendFile } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Download') @ApiTags('Download')
@Controller('download') @Controller('download')
@Authenticated() @Authenticated()
@UseValidation()
export class DownloadController { export class DownloadController {
constructor(private service: DownloadService) {} constructor(private service: DownloadService) {}

View File

@ -2,13 +2,11 @@ import { AssetFaceResponseDto, AuthDto, FaceDto, PersonResponseDto, PersonServic
import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common'; import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Face') @ApiTags('Face')
@Controller('face') @Controller('face')
@Authenticated() @Authenticated()
@UseValidation()
export class FaceController { export class FaceController {
constructor(private service: PersonService) {} constructor(private service: PersonService) {}

View File

@ -2,12 +2,10 @@ import { AllJobStatusResponseDto, JobCommandDto, JobIdParamDto, JobService, JobS
import { Body, Controller, Get, Param, Put } from '@nestjs/common'; import { Body, Controller, Get, Param, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Authenticated } from '../app.guard'; import { Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('Job') @ApiTags('Job')
@Controller('jobs') @Controller('jobs')
@Authenticated({ admin: true }) @Authenticated({ admin: true })
@UseValidation()
export class JobController { export class JobController {
constructor(private service: JobService) {} constructor(private service: JobService) {}

View File

@ -13,13 +13,11 @@ import {
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { AdminRoute, Auth, Authenticated } from '../app.guard'; import { AdminRoute, Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Library') @ApiTags('Library')
@Controller('library') @Controller('library')
@Authenticated() @Authenticated()
@UseValidation()
@AdminRoute() @AdminRoute()
export class LibraryController { export class LibraryController {
constructor(private service: LibraryService) {} constructor(private service: LibraryService) {}

View File

@ -12,12 +12,10 @@ import { Body, Controller, Get, HttpStatus, Post, Redirect, Req, Res } from '@ne
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { Auth, Authenticated, GetLoginDetails, PublicRoute } from '../app.guard'; import { Auth, Authenticated, GetLoginDetails, PublicRoute } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('OAuth') @ApiTags('OAuth')
@Controller('oauth') @Controller('oauth')
@Authenticated() @Authenticated()
@UseValidation()
export class OAuthController { export class OAuthController {
constructor(private service: AuthService) {} constructor(private service: AuthService) {}

View File

@ -3,13 +3,11 @@ import { PartnerResponseDto, UpdatePartnerDto } from '@app/domain/partner/partne
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger'; import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Partner') @ApiTags('Partner')
@Controller('partner') @Controller('partner')
@Authenticated() @Authenticated()
@UseValidation()
export class PartnerController { export class PartnerController {
constructor(private service: PartnerService) {} constructor(private service: PartnerService) {}

View File

@ -17,13 +17,12 @@ import { Body, Controller, Get, Next, Param, Post, Put, Query, Res } from '@nest
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express'; import { NextFunction, Response } from 'express';
import { Auth, Authenticated, FileResponse } from '../app.guard'; import { Auth, Authenticated, FileResponse } from '../app.guard';
import { UseValidation, sendFile } from '../app.utils'; import { sendFile } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Person') @ApiTags('Person')
@Controller('person') @Controller('person')
@Authenticated() @Authenticated()
@UseValidation()
export class PersonController { export class PersonController {
constructor(private service: PersonService) {} constructor(private service: PersonService) {}

View File

@ -15,12 +15,10 @@ import { SearchSuggestionRequestDto } from '@app/domain/search/dto/search-sugges
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common'; import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('Search') @ApiTags('Search')
@Controller('search') @Controller('search')
@Authenticated() @Authenticated()
@UseValidation()
export class SearchController { export class SearchController {
constructor(private service: SearchService) {} constructor(private service: SearchService) {}

View File

@ -12,12 +12,10 @@ import {
import { Controller, Get, HttpCode, HttpStatus, Post } from '@nestjs/common'; import { Controller, Get, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { AdminRoute, Authenticated, PublicRoute } from '../app.guard'; import { AdminRoute, Authenticated, PublicRoute } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('Server Info') @ApiTags('Server Info')
@Controller('server-info') @Controller('server-info')
@Authenticated() @Authenticated()
@UseValidation()
export class ServerInfoController { export class ServerInfoController {
constructor(private service: ServerInfoService) {} constructor(private service: ServerInfoService) {}

View File

@ -13,13 +13,11 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query, Req, Res
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { Auth, Authenticated, SharedLinkRoute } from '../app.guard'; import { Auth, Authenticated, SharedLinkRoute } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Shared Link') @ApiTags('Shared Link')
@Controller('shared-link') @Controller('shared-link')
@Authenticated() @Authenticated()
@UseValidation()
export class SharedLinkController { export class SharedLinkController {
constructor(private readonly service: SharedLinkService) {} constructor(private readonly service: SharedLinkService) {}

View File

@ -3,12 +3,10 @@ import { MapThemeDto } from '@app/domain/system-config/system-config-map-theme.d
import { Body, Controller, Get, Put, Query } from '@nestjs/common'; import { Body, Controller, Get, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { AdminRoute, Authenticated } from '../app.guard'; import { AdminRoute, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('System Config') @ApiTags('System Config')
@Controller('system-config') @Controller('system-config')
@Authenticated({ admin: true }) @Authenticated({ admin: true })
@UseValidation()
export class SystemConfigController { export class SystemConfigController {
constructor(private readonly service: SystemConfigService) {} constructor(private readonly service: SystemConfigService) {}

View File

@ -11,13 +11,11 @@ import {
import { Body, Controller, Delete, Get, Param, Patch, Post, Put } from '@nestjs/common'; import { Body, Controller, Delete, Get, Param, Patch, Post, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('Tag') @ApiTags('Tag')
@Controller('tag') @Controller('tag')
@Authenticated() @Authenticated()
@UseValidation()
export class TagController { export class TagController {
constructor(private service: TagService) {} constructor(private service: TagService) {}

View File

@ -2,12 +2,10 @@ import { AuthDto, BulkIdsDto, TrashService } from '@app/domain';
import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common'; import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard'; import { Auth, Authenticated } from '../app.guard';
import { UseValidation } from '../app.utils';
@ApiTags('Trash') @ApiTags('Trash')
@Controller('trash') @Controller('trash')
@Authenticated() @Authenticated()
@UseValidation()
export class TrashController { export class TrashController {
constructor(private service: TrashService) {} constructor(private service: TrashService) {}

View File

@ -27,14 +27,13 @@ import {
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'; import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express'; import { NextFunction, Response } from 'express';
import { AdminRoute, Auth, Authenticated, FileResponse } from '../app.guard'; import { AdminRoute, Auth, Authenticated, FileResponse } from '../app.guard';
import { UseValidation, sendFile } from '../app.utils'; import { sendFile } from '../app.utils';
import { FileUploadInterceptor, Route } from '../interceptors'; import { FileUploadInterceptor, Route } from '../interceptors';
import { UUIDParamDto } from './dto/uuid-param.dto'; import { UUIDParamDto } from './dto/uuid-param.dto';
@ApiTags('User') @ApiTags('User')
@Controller(Route.USER) @Controller(Route.USER)
@Authenticated() @Authenticated()
@UseValidation()
export class UserController { export class UserController {
constructor(private service: UserService) {} constructor(private service: UserService) {}