hono 1.1.1 → 1.2.2
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 +126 -117
- package/dist/compose.d.ts +2 -2
- package/dist/compose.js +20 -8
- package/dist/compose.test.d.ts +1 -0
- package/dist/compose.test.js +511 -0
- package/dist/context.d.ts +8 -1
- package/dist/context.js +27 -37
- package/dist/context.test.d.ts +1 -0
- package/dist/context.test.js +127 -0
- package/dist/hono.d.ts +44 -21
- package/dist/hono.js +74 -43
- package/dist/hono.test.d.ts +1 -0
- package/dist/hono.test.js +592 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/middleware/basic-auth/index.js +2 -2
- package/dist/middleware/basic-auth/index.test.d.ts +1 -0
- package/dist/middleware/basic-auth/index.test.js +119 -0
- package/dist/middleware/body-parse/index.test.d.ts +1 -0
- package/dist/middleware/body-parse/index.test.js +59 -0
- package/dist/middleware/cookie/index.d.ts +1 -1
- package/dist/middleware/cookie/index.test.d.ts +1 -0
- package/dist/middleware/cookie/index.test.js +54 -0
- package/dist/middleware/cors/index.test.d.ts +1 -0
- package/dist/middleware/cors/index.test.js +59 -0
- package/dist/middleware/etag/index.test.d.ts +1 -0
- package/dist/middleware/etag/index.test.js +45 -0
- package/dist/middleware/graphql-server/index.js +1 -1
- package/dist/middleware/graphql-server/index.test.d.ts +1 -0
- package/dist/middleware/graphql-server/index.test.js +480 -0
- package/dist/middleware/graphql-server/parse-body.test.d.ts +1 -0
- package/dist/middleware/graphql-server/parse-body.test.js +57 -0
- package/dist/middleware/jwt/index.js +9 -11
- package/dist/middleware/jwt/index.test.d.ts +1 -0
- package/dist/middleware/jwt/index.test.js +51 -0
- package/dist/middleware/logger/index.test.d.ts +1 -0
- package/dist/middleware/logger/index.test.js +49 -0
- package/dist/middleware/mustache/index.test.d.ts +1 -0
- package/dist/middleware/mustache/index.test.js +49 -0
- package/dist/middleware/powered-by/index.test.d.ts +1 -0
- package/dist/middleware/powered-by/index.test.js +15 -0
- package/dist/middleware/pretty-json/index.test.d.ts +1 -0
- package/dist/middleware/pretty-json/index.test.js +28 -0
- package/dist/middleware/serve-static/index.test.d.ts +1 -0
- package/dist/middleware/serve-static/index.test.js +58 -0
- package/dist/router/reg-exp-router/index.d.ts +1 -1
- package/dist/router/reg-exp-router/index.js +1 -1
- package/dist/router/reg-exp-router/node.d.ts +3 -0
- package/dist/router/reg-exp-router/node.js +13 -7
- package/dist/router/reg-exp-router/router.d.ts +21 -2
- package/dist/router/reg-exp-router/router.js +301 -81
- package/dist/router/reg-exp-router/router.test.d.ts +1 -0
- package/dist/router/reg-exp-router/router.test.js +212 -0
- package/dist/router/reg-exp-router/trie.d.ts +7 -3
- package/dist/router/reg-exp-router/trie.js +3 -3
- package/dist/router/trie-router/index.d.ts +1 -1
- package/dist/router/trie-router/index.js +1 -1
- package/dist/router/trie-router/node.d.ts +4 -3
- package/dist/router/trie-router/node.js +123 -55
- package/dist/router/trie-router/node.test.d.ts +1 -0
- package/dist/router/trie-router/node.test.js +351 -0
- package/dist/router/trie-router/router.d.ts +2 -2
- package/dist/router/trie-router/router.js +1 -1
- package/dist/router/trie-router/router.test.d.ts +1 -0
- package/dist/router/trie-router/router.test.js +98 -0
- package/dist/router.d.ts +4 -3
- package/dist/router.js +5 -4
- package/dist/utils/body.js +2 -2
- package/dist/utils/body.test.d.ts +1 -0
- package/dist/utils/body.test.js +45 -0
- package/dist/utils/buffer.js +1 -1
- package/dist/utils/buffer.test.d.ts +1 -0
- package/dist/utils/buffer.test.js +36 -0
- package/dist/utils/cloudflare.test.d.ts +1 -0
- package/dist/utils/cloudflare.test.js +42 -0
- package/dist/utils/crypto.test.d.ts +1 -0
- package/dist/utils/crypto.test.js +15 -0
- package/dist/utils/encode.test.d.ts +1 -0
- package/dist/utils/encode.test.js +54 -0
- package/dist/utils/http-status.test.d.ts +1 -0
- package/dist/utils/http-status.test.js +8 -0
- package/dist/utils/jwt/jwt.test.d.ts +1 -0
- package/dist/utils/jwt/jwt.test.js +171 -0
- package/dist/utils/jwt/types.test.d.ts +1 -0
- package/dist/utils/jwt/types.test.js +12 -0
- package/dist/utils/mime.test.d.ts +1 -0
- package/dist/utils/mime.test.js +13 -0
- package/dist/utils/url.js +4 -4
- package/dist/utils/url.test.d.ts +1 -0
- package/dist/utils/url.test.js +87 -0
- package/package.json +3 -4
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const url_1 = require("./url");
|
|
4
|
+
describe('url', () => {
|
|
5
|
+
it('splitPath', () => {
|
|
6
|
+
let ps = (0, url_1.splitPath)('/');
|
|
7
|
+
expect(ps).toStrictEqual(['']);
|
|
8
|
+
ps = (0, url_1.splitPath)('/hello');
|
|
9
|
+
expect(ps).toStrictEqual(['hello']);
|
|
10
|
+
ps = (0, url_1.splitPath)('*');
|
|
11
|
+
expect(ps).toStrictEqual(['*']);
|
|
12
|
+
ps = (0, url_1.splitPath)('/wildcard-abc/*/wildcard-efg');
|
|
13
|
+
expect(ps).toStrictEqual(['wildcard-abc', '*', 'wildcard-efg']);
|
|
14
|
+
ps = (0, url_1.splitPath)('/map/:location/events');
|
|
15
|
+
expect(ps).toStrictEqual(['map', ':location', 'events']);
|
|
16
|
+
});
|
|
17
|
+
it('getPattern', () => {
|
|
18
|
+
let res = (0, url_1.getPattern)(':id');
|
|
19
|
+
expect(res).not.toBeNull();
|
|
20
|
+
expect(res[0]).toBe(':id');
|
|
21
|
+
expect(res[1]).toBe('id');
|
|
22
|
+
expect(res[2]).toBe(true);
|
|
23
|
+
res = (0, url_1.getPattern)(':id{[0-9]+}');
|
|
24
|
+
expect(res[0]).toBe(':id{[0-9]+}');
|
|
25
|
+
expect(res[1]).toBe('id');
|
|
26
|
+
expect(res[2]).toEqual(/^[0-9]+$/);
|
|
27
|
+
res = (0, url_1.getPattern)('*');
|
|
28
|
+
expect(res).toBe('*');
|
|
29
|
+
});
|
|
30
|
+
describe('getPathFromURL', () => {
|
|
31
|
+
it('getPathFromURL - no trailing slash', () => {
|
|
32
|
+
let path = (0, url_1.getPathFromURL)('https://example.com/');
|
|
33
|
+
expect(path).toBe('/');
|
|
34
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello');
|
|
35
|
+
expect(path).toBe('/hello');
|
|
36
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello/hey');
|
|
37
|
+
expect(path).toBe('/hello/hey');
|
|
38
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello?name=foo');
|
|
39
|
+
expect(path).toBe('/hello');
|
|
40
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello/hey?name=foo&name=bar');
|
|
41
|
+
expect(path).toBe('/hello/hey');
|
|
42
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello/hey#fragment');
|
|
43
|
+
expect(path).toBe('/hello/hey');
|
|
44
|
+
});
|
|
45
|
+
it('getPathFromURL - with trailing slash', () => {
|
|
46
|
+
let path = (0, url_1.getPathFromURL)('https://example.com/hello/');
|
|
47
|
+
expect(path).toBe('/hello/');
|
|
48
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello/hey/');
|
|
49
|
+
expect(path).toBe('/hello/hey/');
|
|
50
|
+
});
|
|
51
|
+
it('getPathFromURL - no strict is false', () => {
|
|
52
|
+
let path = (0, url_1.getPathFromURL)('https://example.com/hello/', { strict: false });
|
|
53
|
+
expect(path).toBe('/hello');
|
|
54
|
+
path = (0, url_1.getPathFromURL)('https://example.com/hello/hey/', { strict: false });
|
|
55
|
+
expect(path).toBe('/hello/hey');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('isAbsoluteURL', () => {
|
|
59
|
+
it('absolute url', () => {
|
|
60
|
+
expect((0, url_1.isAbsoluteURL)('https://example.com')).toBeTruthy();
|
|
61
|
+
expect((0, url_1.isAbsoluteURL)('https://example.com/xxx')).toBeTruthy();
|
|
62
|
+
});
|
|
63
|
+
it('relative url', () => {
|
|
64
|
+
expect((0, url_1.isAbsoluteURL)('/')).not.toBeTruthy();
|
|
65
|
+
expect((0, url_1.isAbsoluteURL)('/location')).not.toBeTruthy();
|
|
66
|
+
expect((0, url_1.isAbsoluteURL)('')).not.toBeTruthy();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('mergePath', () => {
|
|
70
|
+
it('mergePath', () => {
|
|
71
|
+
expect((0, url_1.mergePath)('/book', '/')).toBe('/book');
|
|
72
|
+
expect((0, url_1.mergePath)('/book/', '/')).toBe('/book/');
|
|
73
|
+
expect((0, url_1.mergePath)('/book', '/hey')).toBe('/book/hey');
|
|
74
|
+
expect((0, url_1.mergePath)('/book/', '/hey')).toBe('/book/hey');
|
|
75
|
+
expect((0, url_1.mergePath)('/book', '/hey/')).toBe('/book/hey/');
|
|
76
|
+
expect((0, url_1.mergePath)('/book/', '/hey/')).toBe('/book/hey/');
|
|
77
|
+
expect((0, url_1.mergePath)('/book', 'hey', 'say')).toBe('/book/hey/say');
|
|
78
|
+
expect((0, url_1.mergePath)('/book', '/hey/', '/say/')).toBe('/book/hey/say/');
|
|
79
|
+
expect((0, url_1.mergePath)('/book', '/hey/', '/say/', '/')).toBe('/book/hey/say/');
|
|
80
|
+
expect((0, url_1.mergePath)('book', '/')).toBe('/book');
|
|
81
|
+
expect((0, url_1.mergePath)('book/', '/')).toBe('/book/');
|
|
82
|
+
expect((0, url_1.mergePath)('book', '/hey')).toBe('/book/hey');
|
|
83
|
+
expect((0, url_1.mergePath)('book', 'hey')).toBe('/book/hey');
|
|
84
|
+
expect((0, url_1.mergePath)('book', 'hey/')).toBe('/book/hey/');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Ultrafast web framework for Cloudflare Workers.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"test": "jest",
|
|
12
12
|
"lint": "eslint --ext js,ts src .eslintrc.js",
|
|
13
13
|
"lint:fix": "eslint --ext js,ts src .eslintrc.js --fix",
|
|
14
|
-
"build": "rimraf dist && tsc
|
|
15
|
-
"watch": "tsc -w
|
|
14
|
+
"build": "rimraf dist && tsc",
|
|
15
|
+
"watch": "tsc -w",
|
|
16
16
|
"prepublishOnly": "yarn build"
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
@@ -131,7 +131,6 @@
|
|
|
131
131
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
132
132
|
"rimraf": "^3.0.2",
|
|
133
133
|
"ts-jest": "^27.1.4",
|
|
134
|
-
"tsc-alias": "^1.6.7",
|
|
135
134
|
"typescript": "^4.6.3"
|
|
136
135
|
},
|
|
137
136
|
"engines": {
|