response/index.d.ts

46 lines
977 B
TypeScript
Raw Normal View History

2025-01-02 11:03:03 +08:00
import { IncomingMessage, ServerResponse } from 'http'
2025-01-02 10:23:03 +08:00
export default class Response {
status: number
2025-01-02 11:03:03 +08:00
constructor(req: IncomingMessage, res: ServerResponse)
2025-01-02 10:23:03 +08:00
get ended(): boolean
set charset(v: string)
get type(): string
set type(v: string)
set length(val: number)
set body(buf: Buffer | string)
set expires(time: number): void
error(msg: string, statusCode?: number): void
redirect(url: string, f?: boolean): void
location(url: string): void
render(data: string, statusCode?: number): void
sendfile(target: Buffer | string, filename?: string, expires?: number): void
load(file: string, type?: string, expires?: number): void
send(statusCode?: number, msg?: string | object, data?: any): void
get(key: string): string | number | string[]
set(key: string, val: string | string[]): this
delete(key: string): this
append(key: string, val: string): this
cookie(key: string, val: string | number, opts?: object): void
}