@kenniy/godeye-data-contracts
Version:
Enterprise-grade base repository architecture for GOD-EYE microservices with zero overhead and maximum code reuse
35 lines (34 loc) • 1.56 kB
TypeScript
/**
* Smart API Response Decorator
*
* One intelligent decorator that handles everything:
* - Auto-detects pagination vs single response
* - Auto-detects HTTP status codes from method
* - Auto-includes common errors
* - Allows custom error additions
*/
import { Type } from "@nestjs/common";
import { DescriptionConfig } from "./swagger";
interface ApiOptions {
message?: string;
status?: number;
errors?: number[];
excludeCommonErrors?: boolean;
description?: string;
paginated?: boolean;
externalDocUrl?: string;
descriptionConfig?: DescriptionConfig;
optimizeDescription?: boolean;
}
/**
* Smart API Decorator - One decorator to rule them all!
* Auto-detects everything and applies appropriate documentation
*/
export declare function Api<T>(responseDto: Type<T>, options?: ApiOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
/**
* Legacy decorators for backward compatibility
*/
export declare function CommonApiErrors(): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
export declare function ApiResponseWrapper<T>(responseDto: Type<T>, message?: string, statusCode?: number, description?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
export declare function ApiPaginatedWrapper<T>(responseDto: Type<T>, message?: string, description?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
export {};