UNPKG

@creamapi/cream

Version:

Concise REST API Maker - An extension library for express to create REST APIs faster

35 lines (34 loc) 1.84 kB
import { Constructable } from '../../Utils/Constructable'; import { NoCookiesHeaderNames } from './HeadersDef'; export declare const HTTP_HEADERS_METADATA_KEY: unique symbol; /** * This collection of methods allows to push a header to the response * This is structured this way to allow treating multiple values of the same header * at once. * Headers are mainly one value only, but an array of values can be passed to the client * in this case the array is serialized into a string by separating elements with a '<comma><space>', literally * ', '. * Multiple definition of the same header cannot exist in the same request, except for 'Set-Cookie'. * For cookies please use cookie specific functions. * @note THIS DOES NOT APPLY TO COOKIES, USE COOKIES SPECIFIC FUNCTIONS INSTEAD * @param headerName it is the header that is wanted to be set, except for Cookie-related stuff * @returns a collection of functions to act onto the header */ export declare function StaticResponseHeader(headerName: NoCookiesHeaderNames): { /** * This function allows to set the value of a specific header. * Use this function when the header can accept only a single value and * not an array as this will overwrite any previous definitions of the header * @param value the value of the header * @returns the decorator function */ Set: <T extends Constructable>(value: string) => (target: T) => T; /** * This function allows to append a value to a specific header. * Use this function when an array of data needs to be sent to the user via array * do not use it with Set-Cookie as it will not work properly. * @param value the value to be pushed to the header * @returns the decorator function */ Append: <T extends Constructable>(value: string) => (target: T) => T; };