import { ResponseDto } from '../dtos' ; import { applyDecorators , Type } from '@nestjs/common' ; import { ApiOkResponse , getSchemaPath , ApiExtraModels , ApiNotFoundResponse , ApiForbiddenResponse , ApiUnauthorizedResponse , ApiInternalServerErrorResponse , } from '@nestjs/swagger' ; export const ApiGlobalResponse = < TModel extends Type < any > > ( model ) => { return applyDecorators ( ApiExtraModels ( ResponseDto , model ) , ApiOkResponse ( { schema : { allOf : [ { $ref : getSchemaPath ( ResponseDto ) } , { properties : { payload : { $ref : getSchemaPath ( model ) , } , timestamp : { type : 'number' , } , } , } , ] , } , } ) , ApiUnauthorizedResponse ( { description : 'Not authenticated' } ) , ApiForbiddenResponse ( { description : 'Access denied' } ) , ApiNotFoundResponse ( { description : 'Not found' } ) , ApiInternalServerErrorResponse ( { description : 'Server error' } ) ) ; } ;