@mojojs/core
Version:
Real-time web framework
63 lines (62 loc) • 1.5 kB
TypeScript
import type { Context } from '../context.js';
import type { CookieOptions } from '../types.js';
import type { Stream } from 'node:stream';
import { Headers } from '../headers.js';
type SendResponse = (res: ServerResponse, body?: string | Buffer | Stream) => void;
/**
* Server response class.
*/
export declare class ServerResponse {
/**
* Response headers.
*/
headers: Headers;
/**
* Response has already been sent.
*/
isSent: boolean;
/**
* Response status code.
*/
statusCode: number;
/**
* Response status message.
*/
statusMessage: string | null;
_ctx: WeakRef<Context> | undefined;
_sendResponse: SendResponse;
constructor(sendResponse: SendResponse);
/**
* Append header value.
*/
append(name: string, value: string): this;
/**
* Bind context to response.
*/
bindContext(ctx: Context): void;
/**
* Set response content length.
*/
length(len: number): this;
/**
* Send response.
*/
send(body?: string | Buffer | Stream): Promise<void>;
/**
* Set HTTP header for response.
*/
set(name: string, value: string): this;
/**
* Set cookie value.
*/
setCookie(name: string, value: string, options: CookieOptions): this;
/**
* Set response status.
*/
status(code: number, message?: string): this;
/**
* Set response content type.
*/
type(type: string): this;
}
export {};