send helperREserve offers a way to build responses :
statusCode and headers may be specified,noBody prevents the body sending.interface SendOptions {
statusCode?: number /* defaulted to 200 */
headers?: Headers
noBody?: boolean /* do not send body */
}
function send (response: ServerResponse, data: ReadableStream, options?: SendOptions): Promise<void>
function send (response: ServerResponse, data?: string | object, options?: SendOptions): void
Types definition for
send
Headers are defaulted (if not set) depending on the data type :
string :
content-type is set to text/plaincontent-length is calculated based on the UTF-8 encoding byte lengthobject :
content-type is set to application/jsoncontent-length is calculated based on the UTF-8 encoding byte lengthReadableStream : not set