hono 0.5.4 → 0.5.7
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/dist/context.d.ts +1 -1
- package/dist/hono.d.ts +1 -1
- package/dist/middleware/graphql-server/graphql-server.d.ts +25 -0
- package/dist/middleware/graphql-server/graphql-server.js +164 -0
- package/dist/middleware/graphql-server/parse-body.d.ts +3 -0
- package/dist/middleware/graphql-server/parse-body.js +28 -0
- package/dist/router/reg-exp-router/node.d.ts +1 -3
- package/dist/router/reg-exp-router/router.d.ts +1 -9
- package/dist/router/reg-exp-router/router.js +66 -48
- package/package.json +23 -2
package/dist/context.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare class Context<RequestParamKeyType = string> {
|
|
|
12
12
|
private _status;
|
|
13
13
|
private _statusText;
|
|
14
14
|
render: (template: string, params?: object, options?: object) => Promise<Response>;
|
|
15
|
-
notFound: () => Response
|
|
15
|
+
notFound: () => Response | Promise<Response>;
|
|
16
16
|
constructor(req: Request<RequestParamKeyType>, opts?: {
|
|
17
17
|
res: Response;
|
|
18
18
|
env: Env;
|
package/dist/hono.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
}
|
|
13
13
|
export declare type Handler<RequestParamKeyType = string> = (c: Context<RequestParamKeyType>, next?: Function) => Response | Promise<Response>;
|
|
14
14
|
export declare type MiddlewareHandler = (c: Context, next: Function) => Promise<void>;
|
|
15
|
-
export declare type NotFoundHandler = (c: Context) => Response
|
|
15
|
+
export declare type NotFoundHandler = (c: Context) => Response | Promise<Response>;
|
|
16
16
|
export declare type ErrorHandler = (err: Error, c: Context) => Response;
|
|
17
17
|
declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer _Pattern}` ? Name : NameWithPattern;
|
|
18
18
|
declare type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Context } from '../../context';
|
|
2
|
+
import type { GraphQLSchema, ValidationRule } from 'graphql';
|
|
3
|
+
declare type Options = {
|
|
4
|
+
schema: GraphQLSchema;
|
|
5
|
+
rootValue?: unknown;
|
|
6
|
+
pretty?: boolean;
|
|
7
|
+
validationRules?: ReadonlyArray<ValidationRule>;
|
|
8
|
+
};
|
|
9
|
+
export declare const graphqlServer: (options: Options) => (c: Context, next: Function) => Promise<void>;
|
|
10
|
+
export interface GraphQLParams {
|
|
11
|
+
query: string | null;
|
|
12
|
+
variables: {
|
|
13
|
+
readonly [name: string]: unknown;
|
|
14
|
+
} | null;
|
|
15
|
+
operationName: string | null;
|
|
16
|
+
raw: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const getGraphQLParams: (request: Request) => Promise<GraphQLParams>;
|
|
19
|
+
export declare const errorMessages: (messages: string[]) => {
|
|
20
|
+
errors: {
|
|
21
|
+
message: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
export declare const graphiQLResponse: () => void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Based on the code in the `express-graphql` package.
|
|
3
|
+
// https://github.com/graphql/express-graphql/blob/main/src/index.ts
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.graphiQLResponse = exports.errorMessages = exports.getGraphQLParams = exports.graphqlServer = void 0;
|
|
6
|
+
const parse_body_1 = require("./parse-body");
|
|
7
|
+
const graphql_1 = require("graphql");
|
|
8
|
+
const graphqlServer = (options) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const schema = options.schema;
|
|
11
|
+
const rootValue = options.rootValue;
|
|
12
|
+
const pretty = (_a = options.pretty) !== null && _a !== void 0 ? _a : false;
|
|
13
|
+
const validationRules = (_b = options.validationRules) !== null && _b !== void 0 ? _b : [];
|
|
14
|
+
// const showGraphiQL = options.graphiql ?? false
|
|
15
|
+
return async (c, next) => {
|
|
16
|
+
await next();
|
|
17
|
+
// GraphQL HTTP only supports GET and POST methods.
|
|
18
|
+
if (c.req.method !== 'GET' && c.req.method !== 'POST') {
|
|
19
|
+
c.res = c.json((0, exports.errorMessages)(['GraphQL only supports GET and POST requests.']), 405, {
|
|
20
|
+
Allow: 'GET, POST',
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let params;
|
|
25
|
+
try {
|
|
26
|
+
params = await (0, exports.getGraphQLParams)(c.req);
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (e instanceof Error) {
|
|
30
|
+
c.res = c.json((0, exports.errorMessages)([e.message]), 400);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const { query, variables, operationName } = params;
|
|
35
|
+
if (query == null) {
|
|
36
|
+
c.res = c.json((0, exports.errorMessages)(['Must provide query string.']), 400);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const schemaValidationErrors = (0, graphql_1.validateSchema)(schema);
|
|
40
|
+
if (schemaValidationErrors.length > 0) {
|
|
41
|
+
// Return 500: Internal Server Error if invalid schema.
|
|
42
|
+
c.res = c.json((0, exports.errorMessages)(['GraphQL schema validation error.']), 500);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let documentAST;
|
|
46
|
+
try {
|
|
47
|
+
documentAST = (0, graphql_1.parse)(new graphql_1.Source(query, 'GraphQL request'));
|
|
48
|
+
}
|
|
49
|
+
catch (syntaxError) {
|
|
50
|
+
// Return 400: Bad Request if any syntax errors errors exist.
|
|
51
|
+
c.res = c.json((0, exports.errorMessages)(['GraphQL syntax error.']), 400);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Validate AST, reporting any errors.
|
|
55
|
+
const validationErrors = (0, graphql_1.validate)(schema, documentAST, [...graphql_1.specifiedRules, ...validationRules]);
|
|
56
|
+
if (validationErrors.length > 0) {
|
|
57
|
+
// Return 400: Bad Request if any validation errors exist.
|
|
58
|
+
c.res = c.json((0, exports.errorMessages)(['GraphQL validation error.']), 400);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (c.req.method === 'GET') {
|
|
62
|
+
// Determine if this GET request will perform a non-query.
|
|
63
|
+
const operationAST = (0, graphql_1.getOperationAST)(documentAST, operationName);
|
|
64
|
+
if (operationAST && operationAST.operation !== 'query') {
|
|
65
|
+
/*
|
|
66
|
+
Now , does not support GraphiQL
|
|
67
|
+
if (showGraphiQL) {
|
|
68
|
+
//return respondWithGraphiQL(response, graphiqlOptions, params)
|
|
69
|
+
}
|
|
70
|
+
*/
|
|
71
|
+
// Otherwise, report a 405: Method Not Allowed error.
|
|
72
|
+
c.res = c.json((0, exports.errorMessages)([
|
|
73
|
+
`Can only perform a ${operationAST.operation} operation from a POST request.`,
|
|
74
|
+
]), 405, { Allow: 'POST' });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
let result;
|
|
79
|
+
try {
|
|
80
|
+
result = await (0, graphql_1.execute)({
|
|
81
|
+
schema,
|
|
82
|
+
document: documentAST,
|
|
83
|
+
rootValue,
|
|
84
|
+
variableValues: variables,
|
|
85
|
+
operationName: operationName,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
// Return 400: Bad Request if any execution context errors exist.
|
|
90
|
+
c.res = c.json((0, exports.errorMessages)(['GraphQL execution context error.']), 400);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (result.data == null) {
|
|
94
|
+
c.res = c.json((0, exports.errorMessages)([result.errors.toString()]), 500);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
/*
|
|
98
|
+
Now, does not support GraphiQL
|
|
99
|
+
if (showGraphiQL) {
|
|
100
|
+
}
|
|
101
|
+
*/
|
|
102
|
+
if (pretty) {
|
|
103
|
+
const payload = JSON.stringify(result, null, pretty ? 2 : 0);
|
|
104
|
+
c.res = c.text(payload, 200, {
|
|
105
|
+
'Content-Type': 'application/json',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
c.res = c.json(result);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
exports.graphqlServer = graphqlServer;
|
|
115
|
+
const getGraphQLParams = async (request) => {
|
|
116
|
+
var _a, _b, _c;
|
|
117
|
+
const urlData = new URLSearchParams(request.url.split('?')[1]);
|
|
118
|
+
const bodyData = await (0, parse_body_1.parseBody)(request);
|
|
119
|
+
// GraphQL Query string.
|
|
120
|
+
let query = (_a = urlData.get('query')) !== null && _a !== void 0 ? _a : bodyData.query;
|
|
121
|
+
if (typeof query !== 'string') {
|
|
122
|
+
query = null;
|
|
123
|
+
}
|
|
124
|
+
// Parse the variables if needed.
|
|
125
|
+
let variables = ((_b = urlData.get('variables')) !== null && _b !== void 0 ? _b : bodyData.variables);
|
|
126
|
+
if (typeof variables === 'string') {
|
|
127
|
+
try {
|
|
128
|
+
variables = JSON.parse(variables);
|
|
129
|
+
}
|
|
130
|
+
catch (_d) {
|
|
131
|
+
throw Error('Variables are invalid JSON.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (typeof variables !== 'object') {
|
|
135
|
+
variables = null;
|
|
136
|
+
}
|
|
137
|
+
// Name of GraphQL operation to execute.
|
|
138
|
+
let operationName = (_c = urlData.get('operationName')) !== null && _c !== void 0 ? _c : bodyData.operationName;
|
|
139
|
+
if (typeof operationName !== 'string') {
|
|
140
|
+
operationName = null;
|
|
141
|
+
}
|
|
142
|
+
const raw = urlData.get('raw') != null || bodyData.raw !== undefined;
|
|
143
|
+
const params = {
|
|
144
|
+
query: query,
|
|
145
|
+
variables: variables,
|
|
146
|
+
operationName: operationName,
|
|
147
|
+
raw: raw,
|
|
148
|
+
};
|
|
149
|
+
return params;
|
|
150
|
+
};
|
|
151
|
+
exports.getGraphQLParams = getGraphQLParams;
|
|
152
|
+
const errorMessages = (messages) => {
|
|
153
|
+
const errors = messages.map((message) => {
|
|
154
|
+
return {
|
|
155
|
+
message: message,
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
errors: errors,
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
exports.errorMessages = errorMessages;
|
|
163
|
+
const graphiQLResponse = () => { };
|
|
164
|
+
exports.graphiQLResponse = graphiQLResponse;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseBody = void 0;
|
|
4
|
+
async function parseBody(req) {
|
|
5
|
+
const contentType = req.headers.get('content-type');
|
|
6
|
+
switch (contentType) {
|
|
7
|
+
case 'application/graphql':
|
|
8
|
+
return { query: await req.text() };
|
|
9
|
+
case 'application/json':
|
|
10
|
+
try {
|
|
11
|
+
return await req.json();
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
throw Error(`POST body sent invalid JSON: ${e}`);
|
|
15
|
+
}
|
|
16
|
+
case 'application/x-www-form-urlencoded':
|
|
17
|
+
return parseFormURL(req);
|
|
18
|
+
}
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
exports.parseBody = parseBody;
|
|
22
|
+
const parseFormURL = async (req) => {
|
|
23
|
+
const text = await req.text();
|
|
24
|
+
const searchParams = new URLSearchParams(text);
|
|
25
|
+
const res = {};
|
|
26
|
+
searchParams.forEach((v, k) => (res[k] = v));
|
|
27
|
+
return res;
|
|
28
|
+
};
|
|
@@ -5,9 +5,7 @@ export interface Context {
|
|
|
5
5
|
export declare class Node {
|
|
6
6
|
index?: number;
|
|
7
7
|
varIndex?: number;
|
|
8
|
-
children:
|
|
9
|
-
[key: string]: Node;
|
|
10
|
-
};
|
|
8
|
+
children: Record<string, Node>;
|
|
11
9
|
insert(tokens: readonly string[], index: number, paramMap: ParamMap, context: Context): void;
|
|
12
10
|
buildRegExpStr(): string;
|
|
13
11
|
}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { Router, Result } from '../../router';
|
|
2
|
-
import type { ParamMap, ReplacementMap } from './trie';
|
|
3
2
|
declare type Route<T> = [string, T];
|
|
4
|
-
declare type HandlerData<T> = [T, ParamMap];
|
|
5
|
-
declare type Matcher<T> = [RegExp | true, ReplacementMap, HandlerData<T>[]];
|
|
6
3
|
export declare class RegExpRouter<T> extends Router<T> {
|
|
7
|
-
routes?:
|
|
8
|
-
[method: string]: Route<T>[];
|
|
9
|
-
};
|
|
10
|
-
matchers?: {
|
|
11
|
-
[method: string]: Matcher<T> | null;
|
|
12
|
-
};
|
|
4
|
+
routes?: Record<string, Route<T>[]>;
|
|
13
5
|
add(method: string, path: string, handler: T): void;
|
|
14
6
|
match(method: string, path: string): Result<T> | null;
|
|
15
7
|
private buildAllMatchers;
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RegExpRouter = void 0;
|
|
4
4
|
const router_1 = require("../../router");
|
|
5
5
|
const trie_1 = require("./trie");
|
|
6
|
+
const regExpMatchAll = new RegExp('');
|
|
7
|
+
const emptyParam = {};
|
|
6
8
|
class RegExpRouter extends router_1.Router {
|
|
7
9
|
constructor() {
|
|
8
10
|
super(...arguments);
|
|
9
11
|
this.routes = {};
|
|
10
|
-
this.matchers = null;
|
|
11
12
|
}
|
|
12
13
|
add(method, path, handler) {
|
|
13
14
|
var _a;
|
|
@@ -18,43 +19,54 @@ class RegExpRouter extends router_1.Router {
|
|
|
18
19
|
this.routes[method].push([path, handler]);
|
|
19
20
|
}
|
|
20
21
|
match(method, path) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
if (!replacementMap) {
|
|
38
|
-
// there is only one route and no capture
|
|
39
|
-
return new router_1.Result(handlers[0][0], {});
|
|
40
|
-
}
|
|
41
|
-
const index = match.indexOf('', 1);
|
|
42
|
-
const [handler, paramMap] = handlers[replacementMap[index]];
|
|
43
|
-
const params = {};
|
|
44
|
-
for (let i = 0; i < paramMap.length; i++) {
|
|
45
|
-
params[paramMap[i][0]] = match[paramMap[i][1]];
|
|
22
|
+
const matchers = this.buildAllMatchers();
|
|
23
|
+
let match;
|
|
24
|
+
// Optimization for middleware
|
|
25
|
+
const methods = Object.keys(matchers);
|
|
26
|
+
if (methods.length === 1 && methods[0] === router_1.METHOD_NAME_OF_ALL) {
|
|
27
|
+
const [regexp, handlers] = matchers[router_1.METHOD_NAME_OF_ALL];
|
|
28
|
+
if (handlers.length === 1) {
|
|
29
|
+
const result = new router_1.Result(handlers[0][0], emptyParam);
|
|
30
|
+
if (regexp === regExpMatchAll) {
|
|
31
|
+
match = () => result;
|
|
32
|
+
}
|
|
33
|
+
else if (handlers.length === 1 && !handlers[0][1]) {
|
|
34
|
+
match = (_, path) => (regexp.test(path) ? result : null);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
46
37
|
}
|
|
47
|
-
|
|
38
|
+
match || (match = (method, path) => {
|
|
39
|
+
const matcher = matchers[method] || matchers[router_1.METHOD_NAME_OF_ALL];
|
|
40
|
+
if (!matcher) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const match = path.match(matcher[0]);
|
|
44
|
+
if (!match) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const index = match.indexOf('', 1);
|
|
48
|
+
const [handler, paramMap] = matcher[1][index];
|
|
49
|
+
if (!paramMap) {
|
|
50
|
+
return new router_1.Result(handler, emptyParam);
|
|
51
|
+
}
|
|
52
|
+
const params = {};
|
|
53
|
+
for (let i = 0; i < paramMap.length; i++) {
|
|
54
|
+
params[paramMap[i][0]] = match[paramMap[i][1]];
|
|
55
|
+
}
|
|
56
|
+
return new router_1.Result(handler, params);
|
|
57
|
+
});
|
|
58
|
+
this.match = match;
|
|
59
|
+
return this.match(method, path);
|
|
48
60
|
}
|
|
49
61
|
buildAllMatchers() {
|
|
50
|
-
|
|
62
|
+
const matchers = {};
|
|
51
63
|
Object.keys(this.routes).forEach((method) => {
|
|
52
|
-
this.buildMatcher(method);
|
|
64
|
+
matchers[method] = this.buildMatcher(method);
|
|
53
65
|
});
|
|
54
66
|
delete this.routes; // to reduce memory usage
|
|
67
|
+
return matchers;
|
|
55
68
|
}
|
|
56
69
|
buildMatcher(method) {
|
|
57
|
-
this.matchers || (this.matchers = {});
|
|
58
70
|
const trie = new trie_1.Trie();
|
|
59
71
|
const handlers = [];
|
|
60
72
|
const targetMethods = [method];
|
|
@@ -63,34 +75,40 @@ class RegExpRouter extends router_1.Router {
|
|
|
63
75
|
}
|
|
64
76
|
const routes = targetMethods.flatMap((method) => this.routes[method] || []);
|
|
65
77
|
if (routes.length === 0) {
|
|
66
|
-
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (routes.length === 1 && routes[0][0] === '*') {
|
|
70
|
-
this.matchers[method] = [true, null, [[routes[0][1], []]]];
|
|
71
|
-
return;
|
|
78
|
+
return null;
|
|
72
79
|
}
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
if (method === router_1.METHOD_NAME_OF_ALL) {
|
|
81
|
+
if (routes.length === 1 && routes[0][0] === '*') {
|
|
82
|
+
return [regExpMatchAll, [[routes[0][1], null]]];
|
|
83
|
+
}
|
|
84
|
+
if (routes.length === 1 && !routes[0][0].match(/:/)) {
|
|
85
|
+
// there is only one route and no capture
|
|
86
|
+
const tmp = routes[0][0].endsWith('*')
|
|
87
|
+
? routes[0][0].replace(/\/\*$/, '(?:$|/)') // /path/to/* => /path/to(?:$|/)
|
|
88
|
+
: `${routes[0][0]}$`; // /path/to/action => /path/to/action$
|
|
89
|
+
const regExpStr = `^${tmp.replace(/\*/g, '[^/]+')}`; // /prefix/*/path/to => /prefix/[^/]+/path/to
|
|
90
|
+
return [new RegExp(regExpStr), [[routes[0][1], null]]];
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
for (let i = 0; i < routes.length; i++) {
|
|
83
94
|
const paramMap = trie.insert(routes[i][0], i);
|
|
84
|
-
handlers[i] = [routes[i][1], paramMap];
|
|
95
|
+
handlers[i] = [routes[i][1], Object.keys(paramMap).length !== 0 ? paramMap : null];
|
|
85
96
|
}
|
|
86
97
|
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
87
98
|
for (let i = 0; i < handlers.length; i++) {
|
|
88
99
|
const paramMap = handlers[i][1];
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
if (paramMap) {
|
|
101
|
+
for (let i = 0; i < paramMap.length; i++) {
|
|
102
|
+
paramMap[i][1] = paramReplacementMap[paramMap[i][1]];
|
|
103
|
+
}
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
|
-
|
|
106
|
+
const handlerMap = [];
|
|
107
|
+
// using `in` because indexReplacementMap is a sparse array
|
|
108
|
+
for (const i in indexReplacementMap) {
|
|
109
|
+
handlerMap[i] = handlers[indexReplacementMap[i]];
|
|
110
|
+
}
|
|
111
|
+
return [regexp, handlerMap];
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
114
|
exports.RegExpRouter = RegExpRouter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "[炎] Ultrafast web framework for Cloudflare Workers.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,11 +20,16 @@
|
|
|
20
20
|
"./body-parse": "./dist/middleware/body-parse/body-parse.js",
|
|
21
21
|
"./cookie": "./dist/middleware/cookie/cookie.js",
|
|
22
22
|
"./cors": "./dist/middleware/cors/cors.js",
|
|
23
|
+
"./etag": "./dist/middleware/etag/etag.js",
|
|
24
|
+
"./graphql-server": "./dist/middleware/graphql-server/graphql-server.js",
|
|
23
25
|
"./logger": "./dist/middleware/logger/logger.js",
|
|
24
26
|
"./mustache": "./dist/middleware/mustache/mustache.js",
|
|
25
27
|
"./powered-by": "./dist/middleware/powered-by/powered-by.js",
|
|
26
28
|
"./serve-static": "./dist/middleware/serve-static/serve-static.js",
|
|
27
|
-
"./router/
|
|
29
|
+
"./router/trie-router": "./dist/router/trie-router/router.js",
|
|
30
|
+
"./router/reg-exp-router": "./dist/router/reg-exp-router/index.js",
|
|
31
|
+
"./utils/cloudflare": "./dist/utils/cloudflare.js",
|
|
32
|
+
"./utils/mime": "./dist/utils/mime.js"
|
|
28
33
|
},
|
|
29
34
|
"typesVersions": {
|
|
30
35
|
"*": {
|
|
@@ -40,6 +45,12 @@
|
|
|
40
45
|
"cors": [
|
|
41
46
|
"./dist/middleware/cors/cors.d.ts"
|
|
42
47
|
],
|
|
48
|
+
"etag": [
|
|
49
|
+
"./dist/middleware/etag/etag.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"graphql-server": [
|
|
52
|
+
"./dist/middleware/graphql-server/graphql-server.d.ts"
|
|
53
|
+
],
|
|
43
54
|
"logger": [
|
|
44
55
|
"./dist/middleware/logger/logger.d.ts"
|
|
45
56
|
],
|
|
@@ -52,8 +63,17 @@
|
|
|
52
63
|
"serve-static": [
|
|
53
64
|
"./dist/middleware/serve-static/serve-static.d.ts"
|
|
54
65
|
],
|
|
66
|
+
"router/trie-router": [
|
|
67
|
+
"./dist/router/trie-router/router.d.ts"
|
|
68
|
+
],
|
|
55
69
|
"router/reg-exp-router": [
|
|
56
70
|
"./dist/router/reg-exp-router/router.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"utils/cloudflare": [
|
|
73
|
+
"./dist/utils/cloudflare.d.ts"
|
|
74
|
+
],
|
|
75
|
+
"utils/mime": [
|
|
76
|
+
"./dist/utils/mime.d.ts"
|
|
57
77
|
]
|
|
58
78
|
}
|
|
59
79
|
},
|
|
@@ -94,6 +114,7 @@
|
|
|
94
114
|
"eslint-plugin-import": "^2.20.2",
|
|
95
115
|
"eslint-plugin-node": "^11.1.0",
|
|
96
116
|
"form-data": "^4.0.0",
|
|
117
|
+
"graphql": "^16.3.0",
|
|
97
118
|
"jest": "^27.4.5",
|
|
98
119
|
"jest-environment-miniflare": "^2.0.0",
|
|
99
120
|
"mustache": "^4.2.0",
|