From f43372026806f3a201e83f46924966a69b1a0ce4 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 2 Jan 2025 11:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0index.d.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.d.ts | 33 +++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..67c1d9d --- /dev/null +++ b/index.d.ts @@ -0,0 +1,33 @@ +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 + + get cookies(): object + + get headers(): string | object + + get ip(): string +} diff --git a/package.json b/package.json index 848272d..929f047 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "@gm5/request", - "version": "2.0.7", + "version": "2.0.8", "description": "对Http的Request进一步封装, 提供常用的API", "main": "index.js", + "types": "index.d.ts", "author": "yutent", "type": "module", "keywords": [