@nestia/core
Version:
Super-fast validation decorators of NestJS
98 lines (97 loc) • 3.93 kB
TypeScript
import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
import { TypedRoute } from "./TypedRoute";
/**
* Encrypted router decorator functions.
*
* `EncryptedRoute` is a module containing router decorator functions which encrypts
* response body data through AES-128/256 encryption. Furthermore, they can boost
* up JSON string conversion speed about 50x times faster than `class-transformer`,
* even type safe through [typia](https://github.com/samchon/typia).
*
* For reference, if you try to invalid data that is not following the promised
* type `T`, 500 internal server error would be thrown. Also, as `EncryptedRoute`
* composes JSON string through `typia.assertStringify<T>()` function, it is not
* possible to modify response data through interceptors.
*
* - AES-128/256
* - CBC mode
* - PKCS #5 Padding
* - Base64 Encoding
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare namespace EncryptedRoute {
/**
* Encrypted router decorator function for the GET method.
*
* @param paths Path(s) of the HTTP request
* @returns Method decorator
*/
const Get: {
(path?: string | string[]): MethodDecorator;
<T>(stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
<T>(path: string | string[], stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
};
/**
* Encrypted router decorator function for the GET method.
*
* @param paths Path(s) of the HTTP request
* @returns Method decorator
*/
const Post: {
(path?: string | string[]): MethodDecorator;
<T>(stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
<T>(path: string | string[], stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
};
/**
* Encrypted router decorator function for the PATCH method.
*
* @param path Path of the HTTP request
* @returns Method decorator
*/
const Patch: {
(path?: string | string[]): MethodDecorator;
<T>(stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
<T>(path: string | string[], stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
};
/**
* Encrypted router decorator function for the PUT method.
*
* @param path Path of the HTTP request
* @returns Method decorator
*/
const Put: {
(path?: string | string[]): MethodDecorator;
<T>(stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
<T>(path: string | string[], stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
};
/**
* Encrypted router decorator function for the DELETE method.
*
* @param path Path of the HTTP request
* @returns Method decorator
*/
const Delete: {
(path?: string | string[]): MethodDecorator;
<T>(stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
<T>(path: string | string[], stringify?: IResponseBodyStringifier<T> | null): MethodDecorator;
};
/**
* Set the logger function for the response validation failure.
*
* If you've configured the transformation option to `validate.log`
* in the `tsconfig.json` file, then the error log information of the
* response validation failure would be logged through this function
* instead of throwing the 400 bad request error.
*
* By the way, be careful. If you've configured the response
* transformation option to be `validate.log`, client may get wrong
* response data. Therefore, this way is not recommended in the common
* backend server case.
*
* @param func Logger function
* @default console.log
*/
function setValidateErrorLogger(func: (log: IValidateErrorLog) => void): void;
export import IValidateErrorLog = TypedRoute.IValidateErrorLog;
}