@creamapi/cream
Version:
Concise REST API Maker - An extension library for express to create REST APIs faster
28 lines (27 loc) • 1.29 kB
TypeScript
export interface HeaderBuilderInterface {
toConcreteHeader(): string | string[];
}
/**
* This class is a helper cass used to build headers that implement
* custom behaviours and serializing tecniques like cookies
*/
export declare class HeaderBuilder<T = string> extends Array<T> implements HeaderBuilderInterface {
private arraySeparator;
/**
* This class extends Array<string> in order to add the simple but exaustive method
* toConcreteHeader that will convert any arraylike header into a format that is
* HTTP compliant. If there is only one element the returning string won't contain any
* separator.
*
* @param arraySeparator is the separator that will be used to build the final string.
* its default value is ', ' aka comma SP as for https://datatracker.ietf.org/doc/html/rfc9110#name-field-lines-and-combined-fi.
*/
constructor(arraySeparator?: string);
/**
* This method is used to generate the final header based on its content
* It will return a string with elements separated by a comma.
* @returns the string that will correspond to the header. It can return
* an array of strings but this case is useful only for ResponseCookiesManager
*/
toConcreteHeader(): string | string[];
}