samchon / nestia-helper

NestJS helper with Type level
MIT License
34 stars 3 forks source link

Support options for `EncryptedBody()` and `EncryptedRoute()` to turn off their encryption #4

Closed samchon closed 2 years ago

samchon commented 2 years ago

Let EncryptdBody() and EncryptedRoute() to support an option to turning off their encryption algorithm.

If you turn off the encryption algorithm with the closure function, the content like request or response body would be considered as a plain text instead.

/**
 * Encrypted body decorator.
 * 
 * `EncryptedBody` is a decorator function getting special JSON data from the HTTP request 
 * who've encrypted by the AES-125/256 algorithm. Therefore, `EncryptedBody` is suitable
 * for enhancing security by hiding request body data from the client.
 * 
 * Also you don't need to worry about the annyoing encryption and decryption. If you build
 * an SDK library of your HTTP server through the 
 * [nestia](https://github.com/samchon/nestia), such encryption would be automatically 
 * done in the SDK level.
 * 
 * @param ignore Whether to ignore the request body encryption or not. Default is `() => false`.
 * @return Parameter decorator
 * @author Jeongho Nam - https://github.com/samchon
 */
export function EncryptedBody
    (
        ignore?: (ctx: nest.ExecutionContext) => boolean
    ): ParameterDecorator;

export namespace EncryptedRoute
{
        export function Post
        (
            path?: string,
            ignore?: (ctx: nest.ExecutionContext) => boolean
        ): MethodDecorator
}