hono 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/context.js +9 -1
- package/dist/cjs/hono.js +1 -1
- package/dist/cjs/request.js +5 -2
- package/dist/cjs/validator/validator.js +21 -12
- package/dist/context.js +9 -1
- package/dist/hono.js +1 -1
- package/dist/request.js +5 -2
- package/dist/{compose.d.ts → types/compose.d.ts} +0 -0
- package/dist/{context.d.ts → types/context.d.ts} +1 -1
- package/dist/{hono.d.ts → types/hono.d.ts} +0 -0
- package/dist/{index.d.ts → types/index.d.ts} +0 -0
- package/dist/{middleware → types/middleware}/basic-auth/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/bearer-auth/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/cache/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/compress/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/cors/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/etag/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/html/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/jsx/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/jsx/jsx-dev-runtime.d.ts +0 -0
- package/dist/{middleware → types/middleware}/jsx/jsx-runtime.d.ts +0 -0
- package/dist/{middleware → types/middleware}/jwt/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/logger/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/powered-by/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/pretty-json/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/serve-static/bun.d.ts +0 -0
- package/dist/{middleware → types/middleware}/serve-static/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/serve-static/module.d.ts +0 -0
- package/dist/{middleware → types/middleware}/serve-static/serve-static.d.ts +0 -0
- package/dist/{middleware → types/middleware}/validator/index.d.ts +0 -0
- package/dist/{middleware → types/middleware}/validator/middleware.d.ts +0 -0
- package/dist/types/package.json +3 -0
- package/dist/{request.d.ts → types/request.d.ts} +0 -0
- package/dist/{router → types/router}/reg-exp-router/index.d.ts +0 -0
- package/dist/{router → types/router}/reg-exp-router/node.d.ts +0 -0
- package/dist/{router → types/router}/reg-exp-router/router.d.ts +0 -0
- package/dist/{router → types/router}/reg-exp-router/trie.d.ts +0 -0
- package/dist/{router → types/router}/smart-router/index.d.ts +0 -0
- package/dist/{router → types/router}/smart-router/router.d.ts +0 -0
- package/dist/{router → types/router}/static-router/index.d.ts +0 -0
- package/dist/{router → types/router}/static-router/router.d.ts +0 -0
- package/dist/{router → types/router}/trie-router/index.d.ts +0 -0
- package/dist/{router → types/router}/trie-router/node.d.ts +0 -0
- package/dist/{router → types/router}/trie-router/router.d.ts +0 -0
- package/dist/{router.d.ts → types/router.d.ts} +0 -0
- package/dist/{types.d.ts → types/types.d.ts} +0 -0
- package/dist/{utils → types/utils}/body.d.ts +0 -0
- package/dist/{utils → types/utils}/buffer.d.ts +0 -0
- package/dist/{utils → types/utils}/cloudflare.d.ts +0 -0
- package/dist/{utils → types/utils}/cookie.d.ts +0 -0
- package/dist/{utils → types/utils}/crypto.d.ts +0 -0
- package/dist/{utils → types/utils}/encode.d.ts +0 -0
- package/dist/{utils → types/utils}/filepath.d.ts +0 -0
- package/dist/{utils → types/utils}/html.d.ts +0 -0
- package/dist/{utils → types/utils}/http-status.d.ts +0 -0
- package/dist/{utils → types/utils}/json.d.ts +0 -0
- package/dist/{utils → types/utils}/jwt/index.d.ts +0 -0
- package/dist/{utils → types/utils}/jwt/jwt.d.ts +0 -0
- package/dist/{utils → types/utils}/jwt/types.d.ts +0 -0
- package/dist/{utils → types/utils}/mime.d.ts +0 -0
- package/dist/{utils → types/utils}/object.d.ts +0 -0
- package/dist/{utils → types/utils}/types.d.ts +0 -0
- package/dist/{utils → types/utils}/url.d.ts +0 -0
- package/dist/{validator → types/validator}/rule.d.ts +0 -0
- package/dist/{validator → types/validator}/sanitizer.d.ts +0 -0
- package/dist/types/validator/schema.d.ts +10 -0
- package/dist/{validator → types/validator}/validator.d.ts +8 -2
- package/dist/validator/validator.js +21 -12
- package/package.json +54 -53
- package/dist/validator/schema.d.ts +0 -7
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
<hr />
|
|
15
15
|
|
|
16
|
-
[](https://github.com/honojs/hono/actions)
|
|
16
|
+
[](https://github.com/honojs/hono/actions)
|
|
17
17
|
[](https://github.com/honojs/hono/blob/main/LICENSE)
|
|
18
18
|
[](https://www.npmjs.com/package/hono)
|
|
19
19
|
[](https://www.npmjs.com/package/hono)
|
package/dist/cjs/context.js
CHANGED
|
@@ -131,7 +131,12 @@ class Context {
|
|
|
131
131
|
body(data, status = this._status, headers = {}) {
|
|
132
132
|
return this.newResponse(data, status, headers);
|
|
133
133
|
}
|
|
134
|
-
text(text, status
|
|
134
|
+
text(text, status, headers) {
|
|
135
|
+
if (!headers && !status && !this._res && !this._headers) {
|
|
136
|
+
return new Response(text);
|
|
137
|
+
}
|
|
138
|
+
status || (status = this._status);
|
|
139
|
+
headers || (headers = {});
|
|
135
140
|
headers["content-type"] = "text/plain; charset=UTF-8";
|
|
136
141
|
return this.newResponse(text, status, headers);
|
|
137
142
|
}
|
|
@@ -176,6 +181,9 @@ class Context {
|
|
|
176
181
|
if (global?.process?.release?.name === "node") {
|
|
177
182
|
return "node";
|
|
178
183
|
}
|
|
184
|
+
if (global?.__lagon__ !== void 0) {
|
|
185
|
+
return "lagon";
|
|
186
|
+
}
|
|
179
187
|
return "other";
|
|
180
188
|
}
|
|
181
189
|
}
|
package/dist/cjs/hono.js
CHANGED
|
@@ -48,7 +48,7 @@ class Hono extends defineDynamicClass() {
|
|
|
48
48
|
return c.text("404 Not Found", 404);
|
|
49
49
|
};
|
|
50
50
|
this.errorHandler = (err, c) => {
|
|
51
|
-
console.trace(err
|
|
51
|
+
console.trace(err);
|
|
52
52
|
const message = "Internal Server Error";
|
|
53
53
|
return c.text(message, 500);
|
|
54
54
|
};
|
package/dist/cjs/request.js
CHANGED
|
@@ -31,11 +31,14 @@ function extendRequestPrototype() {
|
|
|
31
31
|
Request.prototype.param = function(key) {
|
|
32
32
|
if (this.paramData) {
|
|
33
33
|
if (key) {
|
|
34
|
-
|
|
34
|
+
const param = this.paramData[key];
|
|
35
|
+
return param ? decodeURIComponent(param) : void 0;
|
|
35
36
|
} else {
|
|
36
37
|
const decoded = {};
|
|
37
38
|
for (const [key2, value] of Object.entries(this.paramData)) {
|
|
38
|
-
|
|
39
|
+
if (value) {
|
|
40
|
+
decoded[key2] = decodeURIComponent(value);
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
return decoded;
|
|
41
44
|
}
|
|
@@ -139,16 +139,10 @@ class VBase {
|
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
141
|
this.asNumber = () => {
|
|
142
|
-
|
|
143
|
-
if (this.isArray)
|
|
144
|
-
return newVNumber.asArray();
|
|
145
|
-
return newVNumber;
|
|
142
|
+
return new VNumber({ ...this, type: "number" });
|
|
146
143
|
};
|
|
147
144
|
this.asBoolean = () => {
|
|
148
|
-
|
|
149
|
-
if (this.isArray)
|
|
150
|
-
return newVBoolean.asArray();
|
|
151
|
-
return newVBoolean;
|
|
145
|
+
return new VBoolean({ ...this, type: "boolean" });
|
|
152
146
|
};
|
|
153
147
|
this.validate = async (req) => {
|
|
154
148
|
let value = void 0;
|
|
@@ -201,10 +195,7 @@ class VBase {
|
|
|
201
195
|
}
|
|
202
196
|
return results;
|
|
203
197
|
};
|
|
204
|
-
this.sanitizeValue = (value) => this.sanitizers.reduce(
|
|
205
|
-
(acc, sanitizer2) => sanitizer2(acc),
|
|
206
|
-
value
|
|
207
|
-
);
|
|
198
|
+
this.sanitizeValue = (value) => this.sanitizers.reduce((acc, sanitizer2) => sanitizer2(acc), value);
|
|
208
199
|
this.validateType = (value) => {
|
|
209
200
|
if (this.isArray) {
|
|
210
201
|
if (!Array.isArray(value)) {
|
|
@@ -398,6 +389,12 @@ class VBoolean extends VBase {
|
|
|
398
389
|
class VNumberArray extends VNumber {
|
|
399
390
|
constructor(options) {
|
|
400
391
|
super(options);
|
|
392
|
+
this.asNumber = () => {
|
|
393
|
+
return new VNumberArray({ ...this, type: "number" });
|
|
394
|
+
};
|
|
395
|
+
this.asBoolean = () => {
|
|
396
|
+
return new VBooleanArray({ ...this, type: "boolean" });
|
|
397
|
+
};
|
|
401
398
|
this.isArray = true;
|
|
402
399
|
this.rules[0].name = this.getTypeRuleName();
|
|
403
400
|
}
|
|
@@ -405,6 +402,12 @@ class VNumberArray extends VNumber {
|
|
|
405
402
|
class VStringArray extends VString {
|
|
406
403
|
constructor(options) {
|
|
407
404
|
super(options);
|
|
405
|
+
this.asNumber = () => {
|
|
406
|
+
return new VNumberArray({ ...this, type: "number" });
|
|
407
|
+
};
|
|
408
|
+
this.asBoolean = () => {
|
|
409
|
+
return new VBooleanArray({ ...this, type: "boolean" });
|
|
410
|
+
};
|
|
408
411
|
this.isArray = true;
|
|
409
412
|
this.rules[0].name = this.getTypeRuleName();
|
|
410
413
|
}
|
|
@@ -412,6 +415,12 @@ class VStringArray extends VString {
|
|
|
412
415
|
class VBooleanArray extends VBoolean {
|
|
413
416
|
constructor(options) {
|
|
414
417
|
super(options);
|
|
418
|
+
this.asNumber = () => {
|
|
419
|
+
return new VNumberArray({ ...this, type: "number" });
|
|
420
|
+
};
|
|
421
|
+
this.asBoolean = () => {
|
|
422
|
+
return new VBooleanArray({ ...this, type: "boolean" });
|
|
423
|
+
};
|
|
415
424
|
this.isArray = true;
|
|
416
425
|
this.rules[0].name = this.getTypeRuleName();
|
|
417
426
|
}
|
package/dist/context.js
CHANGED
|
@@ -109,7 +109,12 @@ var Context = class {
|
|
|
109
109
|
body(data, status = this._status, headers = {}) {
|
|
110
110
|
return this.newResponse(data, status, headers);
|
|
111
111
|
}
|
|
112
|
-
text(text, status
|
|
112
|
+
text(text, status, headers) {
|
|
113
|
+
if (!headers && !status && !this._res && !this._headers) {
|
|
114
|
+
return new Response(text);
|
|
115
|
+
}
|
|
116
|
+
status || (status = this._status);
|
|
117
|
+
headers || (headers = {});
|
|
113
118
|
headers["content-type"] = "text/plain; charset=UTF-8";
|
|
114
119
|
return this.newResponse(text, status, headers);
|
|
115
120
|
}
|
|
@@ -154,6 +159,9 @@ var Context = class {
|
|
|
154
159
|
if (global?.process?.release?.name === "node") {
|
|
155
160
|
return "node";
|
|
156
161
|
}
|
|
162
|
+
if (global?.__lagon__ !== void 0) {
|
|
163
|
+
return "lagon";
|
|
164
|
+
}
|
|
157
165
|
return "other";
|
|
158
166
|
}
|
|
159
167
|
};
|
package/dist/hono.js
CHANGED
|
@@ -26,7 +26,7 @@ var Hono = class extends defineDynamicClass() {
|
|
|
26
26
|
return c.text("404 Not Found", 404);
|
|
27
27
|
};
|
|
28
28
|
this.errorHandler = (err, c) => {
|
|
29
|
-
console.trace(err
|
|
29
|
+
console.trace(err);
|
|
30
30
|
const message = "Internal Server Error";
|
|
31
31
|
return c.text(message, 500);
|
|
32
32
|
};
|
package/dist/request.js
CHANGED
|
@@ -9,11 +9,14 @@ function extendRequestPrototype() {
|
|
|
9
9
|
Request.prototype.param = function(key) {
|
|
10
10
|
if (this.paramData) {
|
|
11
11
|
if (key) {
|
|
12
|
-
|
|
12
|
+
const param = this.paramData[key];
|
|
13
|
+
return param ? decodeURIComponent(param) : void 0;
|
|
13
14
|
} else {
|
|
14
15
|
const decoded = {};
|
|
15
16
|
for (const [key2, value] of Object.entries(this.paramData)) {
|
|
16
|
-
|
|
17
|
+
if (value) {
|
|
18
|
+
decoded[key2] = decodeURIComponent(value);
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
return decoded;
|
|
19
22
|
}
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ import type { CookieOptions } from './utils/cookie';
|
|
|
4
4
|
import type { StatusCode } from './utils/http-status';
|
|
5
5
|
import type { Schema, SchemaToProp } from './validator/schema';
|
|
6
6
|
declare type Headers = Record<string, string | string[]>;
|
|
7
|
-
declare type Runtime = 'node' | 'deno' | 'bun' | 'cloudflare' | 'fastly' | 'vercel' | 'other';
|
|
7
|
+
declare type Runtime = 'node' | 'deno' | 'bun' | 'cloudflare' | 'fastly' | 'vercel' | 'lagon' | 'other';
|
|
8
8
|
export declare type Data = string | ArrayBuffer | ReadableStream;
|
|
9
9
|
export declare class Context<P extends string = string, E extends Partial<Environment> = Environment, S = any> {
|
|
10
10
|
req: Request<unknown, P, S extends Schema ? SchemaToProp<S> : S>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VString, VNumber, VBoolean, VObject, VArray, VNumberArray, VStringArray, VBooleanArray, VBase } from './validator';
|
|
2
|
+
export declare type Schema = {
|
|
3
|
+
[key: string]: VString | VNumber | VBoolean | Schema | VObject<Schema> | VArray<Schema>;
|
|
4
|
+
};
|
|
5
|
+
declare type Primitive<T> = T extends VNumberArray ? number[] : T extends VNumber ? number : T extends VStringArray ? string[] : T extends VString ? string : T extends VBooleanArray ? boolean[] : T extends VBoolean ? boolean : T;
|
|
6
|
+
declare type P<T> = T extends VArray<infer R> ? P<R>[] : T extends VObject<infer R> ? P<R> : {
|
|
7
|
+
[K in keyof T]: T[K] extends VBase ? Primitive<T[K]> : T[K] extends VArray<infer R> ? P<R>[] : T[K] extends VObject<infer R> ? P<R> : T[K] extends Schema ? P<T[K]> : never;
|
|
8
|
+
};
|
|
9
|
+
export declare type SchemaToProp<T> = P<T>;
|
|
10
|
+
export {};
|
|
@@ -70,8 +70,8 @@ export declare abstract class VBase {
|
|
|
70
70
|
isRequired: () => this;
|
|
71
71
|
isOptional: () => this;
|
|
72
72
|
isEqual: (comparison: unknown) => this;
|
|
73
|
-
asNumber: () => VNumber
|
|
74
|
-
asBoolean: () => VBoolean
|
|
73
|
+
asNumber: () => VNumber;
|
|
74
|
+
asBoolean: () => VBoolean;
|
|
75
75
|
get(value: string): this;
|
|
76
76
|
validate: <R extends Request<unknown, string, any>>(req: R) => Promise<ValidateResult[]>;
|
|
77
77
|
protected getTypeRuleName(): string;
|
|
@@ -116,13 +116,19 @@ export declare class VBoolean extends VBase {
|
|
|
116
116
|
export declare class VNumberArray extends VNumber {
|
|
117
117
|
isArray: true;
|
|
118
118
|
constructor(options: VOptions);
|
|
119
|
+
asNumber: () => VNumberArray;
|
|
120
|
+
asBoolean: () => VBooleanArray;
|
|
119
121
|
}
|
|
120
122
|
export declare class VStringArray extends VString {
|
|
121
123
|
isArray: true;
|
|
122
124
|
constructor(options: VOptions);
|
|
125
|
+
asNumber: () => VNumberArray;
|
|
126
|
+
asBoolean: () => VBooleanArray;
|
|
123
127
|
}
|
|
124
128
|
export declare class VBooleanArray extends VBoolean {
|
|
125
129
|
isArray: true;
|
|
126
130
|
constructor(options: VOptions);
|
|
131
|
+
asNumber: () => VNumberArray;
|
|
132
|
+
asBoolean: () => VBooleanArray;
|
|
127
133
|
}
|
|
128
134
|
export {};
|
|
@@ -107,16 +107,10 @@ var VBase = class {
|
|
|
107
107
|
});
|
|
108
108
|
};
|
|
109
109
|
this.asNumber = () => {
|
|
110
|
-
|
|
111
|
-
if (this.isArray)
|
|
112
|
-
return newVNumber.asArray();
|
|
113
|
-
return newVNumber;
|
|
110
|
+
return new VNumber({ ...this, type: "number" });
|
|
114
111
|
};
|
|
115
112
|
this.asBoolean = () => {
|
|
116
|
-
|
|
117
|
-
if (this.isArray)
|
|
118
|
-
return newVBoolean.asArray();
|
|
119
|
-
return newVBoolean;
|
|
113
|
+
return new VBoolean({ ...this, type: "boolean" });
|
|
120
114
|
};
|
|
121
115
|
this.validate = async (req) => {
|
|
122
116
|
let value = void 0;
|
|
@@ -169,10 +163,7 @@ var VBase = class {
|
|
|
169
163
|
}
|
|
170
164
|
return results;
|
|
171
165
|
};
|
|
172
|
-
this.sanitizeValue = (value) => this.sanitizers.reduce(
|
|
173
|
-
(acc, sanitizer2) => sanitizer2(acc),
|
|
174
|
-
value
|
|
175
|
-
);
|
|
166
|
+
this.sanitizeValue = (value) => this.sanitizers.reduce((acc, sanitizer2) => sanitizer2(acc), value);
|
|
176
167
|
this.validateType = (value) => {
|
|
177
168
|
if (this.isArray) {
|
|
178
169
|
if (!Array.isArray(value)) {
|
|
@@ -366,6 +357,12 @@ var VBoolean = class extends VBase {
|
|
|
366
357
|
var VNumberArray = class extends VNumber {
|
|
367
358
|
constructor(options) {
|
|
368
359
|
super(options);
|
|
360
|
+
this.asNumber = () => {
|
|
361
|
+
return new VNumberArray({ ...this, type: "number" });
|
|
362
|
+
};
|
|
363
|
+
this.asBoolean = () => {
|
|
364
|
+
return new VBooleanArray({ ...this, type: "boolean" });
|
|
365
|
+
};
|
|
369
366
|
this.isArray = true;
|
|
370
367
|
this.rules[0].name = this.getTypeRuleName();
|
|
371
368
|
}
|
|
@@ -373,6 +370,12 @@ var VNumberArray = class extends VNumber {
|
|
|
373
370
|
var VStringArray = class extends VString {
|
|
374
371
|
constructor(options) {
|
|
375
372
|
super(options);
|
|
373
|
+
this.asNumber = () => {
|
|
374
|
+
return new VNumberArray({ ...this, type: "number" });
|
|
375
|
+
};
|
|
376
|
+
this.asBoolean = () => {
|
|
377
|
+
return new VBooleanArray({ ...this, type: "boolean" });
|
|
378
|
+
};
|
|
376
379
|
this.isArray = true;
|
|
377
380
|
this.rules[0].name = this.getTypeRuleName();
|
|
378
381
|
}
|
|
@@ -380,6 +383,12 @@ var VStringArray = class extends VString {
|
|
|
380
383
|
var VBooleanArray = class extends VBoolean {
|
|
381
384
|
constructor(options) {
|
|
382
385
|
super(options);
|
|
386
|
+
this.asNumber = () => {
|
|
387
|
+
return new VNumberArray({ ...this, type: "number" });
|
|
388
|
+
};
|
|
389
|
+
this.asBoolean = () => {
|
|
390
|
+
return new VBooleanArray({ ...this, type: "boolean" });
|
|
391
|
+
};
|
|
383
392
|
this.isArray = true;
|
|
384
393
|
this.rules[0].name = this.getTypeRuleName();
|
|
385
394
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Ultrafast web framework for Cloudflare Workers, Deno, and Bun.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"test:deno": "deno test --allow-read deno_test",
|
|
15
15
|
"test:bun": "bun wiptest --jsx-import-source ../src/middleware/jsx/jsx-dev-runtime bun_test/index.test.tsx",
|
|
16
|
-
"test:
|
|
16
|
+
"test:lagon": "npx start-server-and-test \"lagon dev lagon_test/index.ts\" http://127.0.0.1:1234 \"yarn jest lagon_test/index.test.ts --testMatch '**/*.test.ts'\"",
|
|
17
|
+
"test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:lagon",
|
|
17
18
|
"lint": "eslint --ext js,ts src .eslintrc.cjs",
|
|
18
19
|
"lint:fix": "eslint --ext js,ts src .eslintrc.cjs --fix",
|
|
19
20
|
"denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.ts'",
|
|
20
|
-
"copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json",
|
|
21
|
+
"copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",
|
|
21
22
|
"build": "rimraf dist && tsx ./build.ts && yarn copy:package.cjs.json",
|
|
22
23
|
"watch": "rimraf dist && tsx ./build.ts --watch && yarn copy:package.cjs.json",
|
|
23
24
|
"prerelease": "yarn denoify && yarn test:deno && yarn build",
|
|
@@ -25,125 +26,125 @@
|
|
|
25
26
|
},
|
|
26
27
|
"exports": {
|
|
27
28
|
".": {
|
|
28
|
-
"types": "./dist/index.d.ts",
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
29
30
|
"import": "./dist/index.js",
|
|
30
31
|
"require": "./dist/cjs/index.js"
|
|
31
32
|
},
|
|
32
33
|
"./basic-auth": {
|
|
33
|
-
"types": "./dist/middleware/basic-auth/index.d.ts",
|
|
34
|
+
"types": "./dist/types/middleware/basic-auth/index.d.ts",
|
|
34
35
|
"import": "./dist/middleware/basic-auth/index.js",
|
|
35
36
|
"require": "./dist/cjs/middleware/basic-auth/index.js"
|
|
36
37
|
},
|
|
37
38
|
"./bearer-auth": {
|
|
38
|
-
"types": "./dist/middleware/bearer-auth/index.d.ts",
|
|
39
|
+
"types": "./dist/types/middleware/bearer-auth/index.d.ts",
|
|
39
40
|
"import": "./dist/middleware/bearer-auth/index.js",
|
|
40
41
|
"require": "./dist/cjs/middleware/bearer-auth/index.js"
|
|
41
42
|
},
|
|
42
43
|
"./cache": {
|
|
43
|
-
"types": "./dist/middleware/cache/index.d.ts",
|
|
44
|
+
"types": "./dist/types/middleware/cache/index.d.ts",
|
|
44
45
|
"import": "./dist/middleware/cache/index.js",
|
|
45
46
|
"require": "./dist/cjs/middleware/cache/index.js"
|
|
46
47
|
},
|
|
47
48
|
"./compress": {
|
|
48
|
-
"types": "./dist/middleware/compress/index.d.ts",
|
|
49
|
+
"types": "./dist/types/middleware/compress/index.d.ts",
|
|
49
50
|
"import": "./dist/middleware/compress/index.js",
|
|
50
51
|
"require": "./dist/cjs/middleware/compress/index.js"
|
|
51
52
|
},
|
|
52
53
|
"./cors": {
|
|
53
|
-
"types": "./dist/middleware/cors/index.d.ts",
|
|
54
|
+
"types": "./dist/types/middleware/cors/index.d.ts",
|
|
54
55
|
"import": "./dist/middleware/cors/index.js",
|
|
55
56
|
"require": "./dist/cjs/middleware/cors/index.js"
|
|
56
57
|
},
|
|
57
58
|
"./etag": {
|
|
58
|
-
"types": "./dist/middleware/etag/index.d.ts",
|
|
59
|
+
"types": "./dist/types/middleware/etag/index.d.ts",
|
|
59
60
|
"import": "./dist/middleware/etag/index.js",
|
|
60
61
|
"require": "./dist/cjs/middleware/etag/index.js"
|
|
61
62
|
},
|
|
62
63
|
"./html": {
|
|
63
|
-
"types": "./dist/middleware/html/index.d.ts",
|
|
64
|
+
"types": "./dist/types/middleware/html/index.d.ts",
|
|
64
65
|
"import": "./dist/middleware/html/index.js",
|
|
65
66
|
"require": "./dist/cjs/middleware/html/index.js"
|
|
66
67
|
},
|
|
67
68
|
"./jsx": {
|
|
68
|
-
"types": "./dist/middleware/jsx/index.d.ts",
|
|
69
|
+
"types": "./dist/types/middleware/jsx/index.d.ts",
|
|
69
70
|
"import": "./dist/middleware/jsx/index.js",
|
|
70
71
|
"require": "./dist/cjs/middleware/jsx/index.js"
|
|
71
72
|
},
|
|
72
73
|
"./jsx/jsx-dev-runtime": {
|
|
73
|
-
"types": "./dist/middleware/jsx/jsx-dev-runtime.d.ts",
|
|
74
|
+
"types": "./dist/types/middleware/jsx/jsx-dev-runtime.d.ts",
|
|
74
75
|
"import": "./dist/middleware/jsx/jsx-dev-runtime.js",
|
|
75
76
|
"require": "./dist/cjs/middleware/jsx/jsx-dev-runtime.js"
|
|
76
77
|
},
|
|
77
78
|
"./jsx/jsx-runtime": {
|
|
78
|
-
"types": "./dist/middleware/jsx/jsx-runtime.d.ts",
|
|
79
|
+
"types": "./dist/types/middleware/jsx/jsx-runtime.d.ts",
|
|
79
80
|
"import": "./dist/middleware/jsx/jsx-runtime.js",
|
|
80
81
|
"require": "./dist/cjs/middleware/jsx/jsx-runtime.js"
|
|
81
82
|
},
|
|
82
83
|
"./jwt": {
|
|
83
|
-
"types": "./dist/middleware/jwt/index.d.ts",
|
|
84
|
+
"types": "./dist/types/middleware/jwt/index.d.ts",
|
|
84
85
|
"import": "./dist/middleware/jwt/index.js",
|
|
85
86
|
"require": "./dist/cjs/middleware/jwt/index.js"
|
|
86
87
|
},
|
|
87
88
|
"./logger": {
|
|
88
|
-
"types": "./dist/middleware/logger/index.d.ts",
|
|
89
|
+
"types": "./dist/types/middleware/logger/index.d.ts",
|
|
89
90
|
"import": "./dist/middleware/logger/index.js",
|
|
90
91
|
"require": "./dist/cjs/middleware/logger/index.js"
|
|
91
92
|
},
|
|
92
93
|
"./powered-by": {
|
|
93
|
-
"types": "./dist/middleware/powered-by/index.d.ts",
|
|
94
|
+
"types": "./dist/types/middleware/powered-by/index.d.ts",
|
|
94
95
|
"import": "./dist/middleware/powered-by/index.js",
|
|
95
96
|
"require": "./dist/cjs/middleware/powered-by/index.js"
|
|
96
97
|
},
|
|
97
98
|
"./pretty-json": {
|
|
98
|
-
"types": "./dist/middleware/pretty-json/index.d.ts",
|
|
99
|
+
"types": "./dist/types/middleware/pretty-json/index.d.ts",
|
|
99
100
|
"import": "./dist/middleware/pretty-json/index.js",
|
|
100
101
|
"require": "./dist/cjs/middleware/pretty-json/index.js"
|
|
101
102
|
},
|
|
102
103
|
"./serve-static": {
|
|
103
|
-
"types": "./dist/middleware/serve-static/index.d.ts",
|
|
104
|
+
"types": "./dist/types/middleware/serve-static/index.d.ts",
|
|
104
105
|
"import": "./dist/middleware/serve-static/index.js",
|
|
105
106
|
"require": "./dist/cjs/middleware/serve-static/index.js"
|
|
106
107
|
},
|
|
107
108
|
"./serve-static.bun": {
|
|
108
|
-
"types": "./dist/middleware/serve-static/bun.d.ts",
|
|
109
|
+
"types": "./dist/types/middleware/serve-static/bun.d.ts",
|
|
109
110
|
"import": "./dist/middleware/serve-static/bun.js",
|
|
110
111
|
"require": "./dist/cjs/middleware/serve-static/bun.js"
|
|
111
112
|
},
|
|
112
113
|
"./serve-static.module": {
|
|
113
|
-
"types": "./dist/middleware/serve-static/module.d.ts",
|
|
114
|
+
"types": "./dist/types/middleware/serve-static/module.d.ts",
|
|
114
115
|
"import": "./dist/middleware/serve-static/module.js"
|
|
115
116
|
},
|
|
116
117
|
"./validator": {
|
|
117
|
-
"types": "./dist/middleware/validator/index.d.ts",
|
|
118
|
+
"types": "./dist/types/middleware/validator/index.d.ts",
|
|
118
119
|
"import": "./dist/middleware/validator/index.js",
|
|
119
120
|
"require": "./dist/cjs/middleware/validator/index.js"
|
|
120
121
|
},
|
|
121
122
|
"./router/reg-exp-router": {
|
|
122
|
-
"types": "./dist/router/reg-exp-router/index.d.ts",
|
|
123
|
+
"types": "./dist/types/router/reg-exp-router/index.d.ts",
|
|
123
124
|
"import": "./dist/router/reg-exp-router/index.js",
|
|
124
125
|
"require": "./dist/cjs/router/reg-exp-router/index.js"
|
|
125
126
|
},
|
|
126
127
|
"./router/smart-router": {
|
|
127
|
-
"types": "./dist/router/smart-router/index.d.ts",
|
|
128
|
+
"types": "./dist/types/router/smart-router/index.d.ts",
|
|
128
129
|
"import": "./dist/router/smart-router/index.js",
|
|
129
130
|
"require": "./dist/cjs/router/smart-router/index.js"
|
|
130
131
|
},
|
|
131
132
|
"./router/static-router": {
|
|
132
|
-
"import": "./dist/router/static-router/index.js",
|
|
133
|
+
"import": "./dist/types/router/static-router/index.js",
|
|
133
134
|
"require": "./dist/cjs/router/static-router/index.js"
|
|
134
135
|
},
|
|
135
136
|
"./router/trie-router": {
|
|
136
|
-
"types": "./dist/router/trie-router/index.d.ts",
|
|
137
|
+
"types": "./dist/types/router/trie-router/index.d.ts",
|
|
137
138
|
"import": "./dist/router/trie-router/index.js",
|
|
138
139
|
"require": "./dist/cjs/router/trie-router/index.js"
|
|
139
140
|
},
|
|
140
141
|
"./utils/jwt": {
|
|
141
|
-
"types": "./dist/utils/jwt/index.d.ts",
|
|
142
|
+
"types": "./dist/types/utils/jwt/index.d.ts",
|
|
142
143
|
"import": "./dist/utils/jwt/index.js",
|
|
143
144
|
"require": "./dist/cjs/utils/jwt/index.js"
|
|
144
145
|
},
|
|
145
146
|
"./utils/*": {
|
|
146
|
-
"types": "./dist/utils/*.d.ts",
|
|
147
|
+
"types": "./dist/types/utils/*.d.ts",
|
|
147
148
|
"import": "./dist/utils/*.js",
|
|
148
149
|
"require": "./dist/cjs/utils/*.js"
|
|
149
150
|
}
|
|
@@ -151,76 +152,76 @@
|
|
|
151
152
|
"typesVersions": {
|
|
152
153
|
"*": {
|
|
153
154
|
"basic-auth": [
|
|
154
|
-
"./dist/middleware/basic-auth"
|
|
155
|
+
"./dist/types/middleware/basic-auth"
|
|
155
156
|
],
|
|
156
157
|
"bearer-auth": [
|
|
157
|
-
"./dist/middleware/bearer-auth"
|
|
158
|
+
"./dist/types/middleware/bearer-auth"
|
|
158
159
|
],
|
|
159
160
|
"cache": [
|
|
160
|
-
"./dist/middleware/cache"
|
|
161
|
+
"./dist/types/middleware/cache"
|
|
161
162
|
],
|
|
162
163
|
"compress": [
|
|
163
|
-
"./dist/middleware/compress"
|
|
164
|
+
"./dist/types/middleware/compress"
|
|
164
165
|
],
|
|
165
166
|
"cors": [
|
|
166
|
-
"./dist/middleware/cors"
|
|
167
|
+
"./dist/types/middleware/cors"
|
|
167
168
|
],
|
|
168
169
|
"etag": [
|
|
169
|
-
"./dist/middleware/etag"
|
|
170
|
+
"./dist/types/middleware/etag"
|
|
170
171
|
],
|
|
171
172
|
"html": [
|
|
172
|
-
"./dist/middleware/html"
|
|
173
|
+
"./dist/types/middleware/html"
|
|
173
174
|
],
|
|
174
175
|
"jsx": [
|
|
175
|
-
"./dist/middleware/jsx"
|
|
176
|
+
"./dist/types/middleware/jsx"
|
|
176
177
|
],
|
|
177
178
|
"jsx/jsx-runtime": [
|
|
178
|
-
"./dist/middleware/jsx/jsx-runtime.d.ts"
|
|
179
|
+
"./dist/types/middleware/jsx/jsx-runtime.d.ts"
|
|
179
180
|
],
|
|
180
181
|
"jsx/jsx-dev-runtime": [
|
|
181
|
-
"./dist/middleware/jsx/jsx-dev-runtime.d.ts"
|
|
182
|
+
"./dist/types/middleware/jsx/jsx-dev-runtime.d.ts"
|
|
182
183
|
],
|
|
183
184
|
"jwt": [
|
|
184
|
-
"./dist/middleware/jwt"
|
|
185
|
+
"./dist/types/middleware/jwt"
|
|
185
186
|
],
|
|
186
187
|
"logger": [
|
|
187
|
-
"./dist/middleware/logger"
|
|
188
|
+
"./dist/types/middleware/logger"
|
|
188
189
|
],
|
|
189
190
|
"powered-by": [
|
|
190
|
-
"./dist/middleware/powered-by"
|
|
191
|
+
"./dist/types/middleware/powered-by"
|
|
191
192
|
],
|
|
192
193
|
"pretty-json": [
|
|
193
|
-
"./dist/middleware/pretty-json"
|
|
194
|
+
"./dist/types/middleware/pretty-json"
|
|
194
195
|
],
|
|
195
196
|
"serve-static": [
|
|
196
|
-
"./dist/middleware/serve-static/index.d.ts"
|
|
197
|
+
"./dist/types/middleware/serve-static/index.d.ts"
|
|
197
198
|
],
|
|
198
199
|
"serve-static.bun": [
|
|
199
|
-
"./dist/middleware/serve-static/bun.d.ts"
|
|
200
|
+
"./dist/types/middleware/serve-static/bun.d.ts"
|
|
200
201
|
],
|
|
201
202
|
"serve-static.module": [
|
|
202
|
-
"./dist/middleware/serve-static/module.d.ts"
|
|
203
|
+
"./dist/types/middleware/serve-static/module.d.ts"
|
|
203
204
|
],
|
|
204
205
|
"validator": [
|
|
205
|
-
"./dist/middleware/validator"
|
|
206
|
+
"./dist/types/middleware/validator"
|
|
206
207
|
],
|
|
207
208
|
"router/reg-exp-router": [
|
|
208
|
-
"./dist/router/reg-exp-router/router.d.ts"
|
|
209
|
+
"./dist/types/router/reg-exp-router/router.d.ts"
|
|
209
210
|
],
|
|
210
211
|
"router/smart-router": [
|
|
211
|
-
"./dist/router/smart-router/router.d.ts"
|
|
212
|
+
"./dist/types/router/smart-router/router.d.ts"
|
|
212
213
|
],
|
|
213
214
|
"router/static-router": [
|
|
214
|
-
"./dist/router/static-router/router.d.ts"
|
|
215
|
+
"./dist/types/router/static-router/router.d.ts"
|
|
215
216
|
],
|
|
216
217
|
"router/trie-router": [
|
|
217
|
-
"./dist/router/trie-router/router.d.ts"
|
|
218
|
+
"./dist/types/router/trie-router/router.d.ts"
|
|
218
219
|
],
|
|
219
220
|
"utils/jwt": [
|
|
220
|
-
"./dist/utils/jwt/index.d.ts"
|
|
221
|
+
"./dist/types/utils/jwt/index.d.ts"
|
|
221
222
|
],
|
|
222
223
|
"utils/*": [
|
|
223
|
-
"./dist/utils/*"
|
|
224
|
+
"./dist/types/utils/*"
|
|
224
225
|
]
|
|
225
226
|
}
|
|
226
227
|
},
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { VString, VNumber, VBoolean, VObject, VNumberArray, VStringArray, VBooleanArray, VArray, VObjectBase } from './validator';
|
|
2
|
-
export declare type Schema = {
|
|
3
|
-
[key: string]: VString | VNumber | VBoolean | VStringArray | VNumberArray | VBooleanArray | Schema | VObject<Schema> | VArray<Schema>;
|
|
4
|
-
};
|
|
5
|
-
export declare type SchemaToProp<T> = T extends VArray<infer R> ? SchemaToProp<R>[] : T extends VObject<infer R> ? SchemaToProp<R> : {
|
|
6
|
-
[K in keyof T]: T[K] extends VNumberArray ? number[] : T[K] extends VBooleanArray ? boolean[] : T[K] extends VStringArray ? string[] : T[K] extends VString ? string : T[K] extends VNumber ? number : T[K] extends VBoolean ? boolean : T[K] extends VObjectBase<Schema> ? T[K]['container'] extends VNumber ? number : T[K]['container'] extends VString ? string : T[K]['container'] extends VBoolean ? boolean : T[K] extends VArray<infer R> ? SchemaToProp<R>[] : T[K] extends VObject<infer R> ? SchemaToProp<R> : T[K] extends Schema ? SchemaToProp<T[K]> : never : SchemaToProp<T[K]>;
|
|
7
|
-
};
|