request/index.d.ts

34 lines
575 B
TypeScript

import { IncomingMessage, ServerResponse } from 'http'
declare type Config = {
encoding: string
uploadDir: string
}
export default class Request {
controller: string
method: string
path: string[]
url: string
host: string
hostname: string
protocol: string
constructor(req: IncomingMessage, res: ServerResponse, opts?: Config)
header(key?: string): string | object
cookie(key?: string): string | object
get query(): object
get body(): Promise<object | Buffer>
get cookies(): object
get headers(): string | object
get ip(): string
}
对Http的request进一步封装, 提供常用的API
JavaScript 100%