From 48803cebfcccfaf9d24b8496f5088b9acf330bbd Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 2 Jan 2025 10:23:03 +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 | 45 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 47 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..943cde3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,45 @@ +import { ServerRequest, ServerResponse } from 'http' + +export default class Response { + status: number + + constructor(req: ServerRequest, res: ServerResponse) + + 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 +} diff --git a/package.json b/package.json index d94996f..6a26059 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "@gm5/response", - "version": "2.1.1", + "version": "2.1.2", "type": "module", "description": "对Http的response进一步封装, 提供常用的API", "main": "index.js", + "types": "index.d.ts", "author": "yutent", "keywords": [ "fivejs",