hono 0.5.8 → 1.0.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.
Files changed (48) hide show
  1. package/README.md +27 -20
  2. package/dist/context.d.ts +11 -6
  3. package/dist/context.js +27 -20
  4. package/dist/hono.d.ts +22 -25
  5. package/dist/hono.js +20 -40
  6. package/dist/index.d.ts +1 -1
  7. package/dist/middleware/basic-auth/{basic-auth.d.ts → index.d.ts} +2 -1
  8. package/dist/middleware/basic-auth/{basic-auth.js → index.js} +0 -0
  9. package/dist/middleware/body-parse/index.d.ts +3 -0
  10. package/dist/middleware/body-parse/{body-parse.js → index.js} +0 -0
  11. package/dist/middleware/cookie/{cookie.d.ts → index.d.ts} +3 -2
  12. package/dist/middleware/cookie/{cookie.js → index.js} +1 -1
  13. package/dist/middleware/cors/{cors.d.ts → index.d.ts} +2 -1
  14. package/dist/middleware/cors/{cors.js → index.js} +0 -0
  15. package/dist/middleware/etag/{etag.d.ts → index.d.ts} +2 -1
  16. package/dist/middleware/etag/{etag.js → index.js} +1 -1
  17. package/dist/middleware/graphql-server/{graphql-server.d.ts → index.d.ts} +7 -4
  18. package/dist/middleware/graphql-server/{graphql-server.js → index.js} +34 -17
  19. package/dist/middleware/graphql-server/parse-body.js +3 -0
  20. package/dist/middleware/logger/{logger.d.ts → index.d.ts} +2 -1
  21. package/dist/middleware/logger/{logger.js → index.js} +2 -2
  22. package/dist/middleware/mustache/{mustache.d.ts → index.d.ts} +2 -1
  23. package/dist/middleware/mustache/{mustache.js → index.js} +0 -0
  24. package/dist/middleware/powered-by/index.d.ts +3 -0
  25. package/dist/middleware/powered-by/{powered-by.js → index.js} +0 -1
  26. package/dist/middleware/pretty-json/index.d.ts +7 -0
  27. package/dist/middleware/pretty-json/index.js +11 -0
  28. package/dist/middleware/serve-static/{serve-static.d.ts → index.d.ts} +2 -1
  29. package/dist/middleware/serve-static/{serve-static.js → index.js} +1 -1
  30. package/dist/router/reg-exp-router/index.d.ts +1 -1
  31. package/dist/router/reg-exp-router/index.js +1 -1
  32. package/dist/router/reg-exp-router/router.js +1 -1
  33. package/dist/router/reg-exp-router/trie.d.ts +3 -3
  34. package/dist/router/reg-exp-router/trie.js +1 -1
  35. package/dist/router/trie-router/index.d.ts +1 -1
  36. package/dist/router/trie-router/index.js +1 -1
  37. package/dist/router/trie-router/node.d.ts +1 -1
  38. package/dist/router/trie-router/node.js +1 -1
  39. package/dist/router/trie-router/router.d.ts +1 -1
  40. package/dist/router/trie-router/router.js +1 -1
  41. package/dist/utils/buffer.js +1 -1
  42. package/dist/utils/crypto.d.ts +2 -2
  43. package/dist/utils/crypto.js +6 -0
  44. package/dist/utils/http-status.d.ts +2 -1
  45. package/dist/utils/http-status.js +6 -2
  46. package/package.json +35 -37
  47. package/dist/middleware/body-parse/body-parse.d.ts +0 -2
  48. package/dist/middleware/powered-by/powered-by.d.ts +0 -2
package/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Hono\[炎\]
1
+ <div align="center">
2
+ <a href="https://github.com/yusukebe/hono">
3
+ <img src="https://raw.githubusercontent.com/yusukebe/hono/master/docs/images/hono-title.png" width="500" height="auto" alt="Hono"/>
4
+ </a>
5
+ </div>
6
+
7
+ <hr />
2
8
 
3
9
  <p>
4
10
  <a href="https://github.com/yusukebe/hono/blob/master/README.md">English</a>
@@ -14,7 +20,7 @@
14
20
  [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/yusukebe/hono)](https://github.com/yusukebe/hono/pulse)
15
21
  [![GitHub last commit](https://img.shields.io/github/last-commit/yusukebe/hono)](https://github.com/yusukebe/hono/commits/master)
16
22
 
17
- Hono[炎] - _**means flame🔥 in Japanese**_ - is small, simple, and ultrafast web framework for Cloudflare Workers and Fastly Compute@Edge.
23
+ Hono - _**[炎] means flame🔥 in Japanese**_ - is small, simple, and ultrafast web framework for Cloudflare Workers and Fastly Compute@Edge.
18
24
 
19
25
  ```js
20
26
  import { Hono } from 'hono'
@@ -30,6 +36,7 @@ app.fire()
30
36
  - **Ultrafast** - the router does not use linear loops.
31
37
  - **Zero-dependencies** - using only Service Worker and Web standard API.
32
38
  - **Middleware** - built-in middleware and ability to extend with your own middleware.
39
+ - **TypeScript** - first-class TypeScript support.
33
40
  - **Optimized** - for Cloudflare Workers.
34
41
 
35
42
  ## Benchmark
@@ -59,14 +66,14 @@ Now, the named path parameter has types.
59
66
 
60
67
  You can install Hono from the npm registry.
61
68
 
62
- ```
63
- $ yarn add hono
69
+ ```sh
70
+ yarn add hono
64
71
  ```
65
72
 
66
73
  or
67
74
 
68
- ```
69
- $ npm install hono
75
+ ```sh
76
+ npm install hono
70
77
  ```
71
78
 
72
79
  ## Methods
@@ -420,18 +427,18 @@ Let's write your first code for Cloudflare Workers with Hono.
420
427
 
421
428
  Make a npm skeleton directory.
422
429
 
423
- ```
424
- $ mkdir hono-example
425
- $ cd hono-example
426
- $ npm init -y
430
+ ```sh
431
+ mkdir hono-example
432
+ cd hono-example
433
+ npm init -y
427
434
  ```
428
435
 
429
436
  ### 2. `wrangler init`
430
437
 
431
438
  Initialize as a wrangler project.
432
439
 
433
- ```
434
- $ npx wrangler@beta init
440
+ ```sh
441
+ npx wrangler@beta init
435
442
  ```
436
443
 
437
444
  Answer the questions. If you want, you can answer `y`.
@@ -446,8 +453,8 @@ Would you like to create a Worker at src/index.js? (y/n) <--- n
446
453
 
447
454
  Install `hono` from the npm registry.
448
455
 
449
- ```
450
- $ npm i hono
456
+ ```sh
457
+ npm i hono
451
458
  ```
452
459
 
453
460
  ### 4. Write your app
@@ -468,16 +475,16 @@ app.fire()
468
475
 
469
476
  Run the development server locally. Then, access `http://127.0.0.1:8787/` in your Web browser.
470
477
 
471
- ```
472
- $ npx wrangler@beta dev index.js
478
+ ```sh
479
+ npx wrangler@beta dev index.js
473
480
  ```
474
481
 
475
482
  ### 6. Publish
476
483
 
477
484
  Deploy to Cloudflare. That's all!
478
485
 
479
- ```
480
- $ npx wrangler@beta publish index.js
486
+ ```sh
487
+ npx wrangler@beta publish index.js
481
488
  ```
482
489
 
483
490
  ## Starter template
@@ -486,8 +493,8 @@ You can start making your Cloudflare Workers application with [the starter templ
486
493
 
487
494
  To generate a project skelton, run this command.
488
495
 
489
- ```
490
- $ wrangler generate my-app https://github.com/yusukebe/hono-minimal
496
+ ```sh
497
+ wrangler generate my-app https://github.com/yusukebe/hono-minimal
491
498
  ```
492
499
 
493
500
  ## Related projects
package/dist/context.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
+ import type { StatusCode } from './utils/http-status';
2
3
  declare type Headers = Record<string, string>;
3
4
  declare type Data = string | ArrayBuffer | ReadableStream;
4
5
  export interface Env {
@@ -11,6 +12,8 @@ export declare class Context<RequestParamKeyType = string> {
11
12
  private _headers;
12
13
  private _status;
13
14
  private _statusText;
15
+ private _pretty;
16
+ private _prettySpace;
14
17
  render: (template: string, params?: object, options?: object) => Promise<Response>;
15
18
  notFound: () => Response | Promise<Response>;
16
19
  constructor(req: Request<RequestParamKeyType>, opts?: {
@@ -18,13 +21,15 @@ export declare class Context<RequestParamKeyType = string> {
18
21
  env: Env;
19
22
  event: FetchEvent;
20
23
  });
24
+ private initRequest;
21
25
  header(name: string, value: string): void;
22
- status(number: number): void;
26
+ status(status: StatusCode): void;
27
+ pretty(prettyJSON: boolean, space?: number): void;
23
28
  newResponse(data: Data, init?: ResponseInit): Response;
24
- body(data: Data, status?: number, headers?: Headers): Response;
25
- text(text: string, status?: number, headers?: Headers): Response;
26
- json(object: object, status?: number, headers?: Headers): Response;
27
- html(html: string, status?: number, headers?: Headers): Response;
28
- redirect(location: string, status?: number): Response;
29
+ body(data: Data, status?: StatusCode, headers?: Headers): Response;
30
+ text(text: string, status?: StatusCode, headers?: Headers): Response;
31
+ json(object: object, status?: StatusCode, headers?: Headers): Response;
32
+ html(html: string, status?: StatusCode, headers?: Headers): Response;
33
+ redirect(location: string, status?: StatusCode): Response;
29
34
  }
30
35
  export {};
package/dist/context.js CHANGED
@@ -1,42 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Context = void 0;
4
- const url_1 = require("./utils/url");
5
4
  const http_status_1 = require("./utils/http-status");
5
+ const url_1 = require("./utils/url");
6
6
  class Context {
7
7
  constructor(req, opts) {
8
- this.req = req;
9
- if (opts) {
10
- this.res = opts.res;
11
- this.env = opts.env;
12
- this.event = opts.event;
13
- }
8
+ this._prettySpace = 2;
9
+ this.req = this.initRequest(req);
10
+ Object.assign(this, opts);
14
11
  this._headers = {};
15
12
  }
13
+ initRequest(req) {
14
+ req.header = (name) => {
15
+ return req.headers.get(name);
16
+ };
17
+ req.query = (key) => {
18
+ const url = new URL(req.url);
19
+ return url.searchParams.get(key);
20
+ };
21
+ return req;
22
+ }
16
23
  header(name, value) {
17
- /*
18
- XXX:
19
- app.use('*', (c, next) => {
20
- next()
21
- c.header('foo', 'bar') // => c.res.headers.set(...)
22
- })
23
- */
24
24
  if (this.res) {
25
25
  this.res.headers.set(name, value);
26
26
  }
27
27
  this._headers[name] = value;
28
28
  }
29
- status(number) {
29
+ status(status) {
30
30
  if (this.res) {
31
31
  console.warn('c.res.status is already set.');
32
32
  return;
33
33
  }
34
- this._status = number;
35
- this._statusText = (0, http_status_1.getStatusText)(number);
34
+ this._status = status;
35
+ this._statusText = (0, http_status_1.getStatusText)(status);
36
+ }
37
+ pretty(prettyJSON, space = 2) {
38
+ this._pretty = prettyJSON;
39
+ this._prettySpace = space;
36
40
  }
37
41
  newResponse(data, init = {}) {
38
42
  init.status = init.status || this._status || 200;
39
- init.statusText = init.statusText || this._statusText || (0, http_status_1.getStatusText)(init.status);
43
+ init.statusText =
44
+ init.statusText || this._statusText || (0, http_status_1.getStatusText)(init.status);
40
45
  init.headers = Object.assign(Object.assign({}, this._headers), init.headers);
41
46
  // Content-Length
42
47
  let length = 0;
@@ -67,9 +72,11 @@ class Context {
67
72
  }
68
73
  json(object, status = this._status, headers = {}) {
69
74
  if (typeof object !== 'object') {
70
- throw new TypeError('json method arg must be a object!');
75
+ throw new TypeError('json method arg must be an object!');
71
76
  }
72
- const body = JSON.stringify(object);
77
+ const body = this._pretty
78
+ ? JSON.stringify(object, null, this._prettySpace)
79
+ : JSON.stringify(object);
73
80
  headers['Content-Type'] || (headers['Content-Type'] = 'application/json; charset=UTF-8');
74
81
  return this.body(body, status, headers);
75
82
  }
package/dist/hono.d.ts CHANGED
@@ -10,47 +10,44 @@ declare global {
10
10
  parsedBody: any;
11
11
  }
12
12
  }
13
- export declare type Handler<RequestParamKeyType = string> = (c: Context<RequestParamKeyType>, next?: Function) => Response | Promise<Response>;
14
- export declare type MiddlewareHandler = (c: Context, next: Function) => Promise<void>;
13
+ export declare type Handler<RequestParamKeyType = string> = (c: Context<RequestParamKeyType | string>, next?: Next) => Response | Promise<Response>;
14
+ export declare type MiddlewareHandler = (c: Context, next: Next) => Promise<void>;
15
15
  export declare type NotFoundHandler = (c: Context) => Response | Promise<Response>;
16
16
  export declare type ErrorHandler = (err: Error, c: Context) => Response;
17
+ export declare type Next = () => Promise<void>;
17
18
  declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer _Pattern}` ? Name : NameWithPattern;
18
19
  declare type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
19
20
  declare type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
20
- export declare class Hono {
21
- routerClass: {
21
+ declare const Hono_base: new () => {
22
+ delete: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
23
+ get: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
24
+ post: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
25
+ put: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
26
+ head: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
27
+ options: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
28
+ patch: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
29
+ all: <Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>) => Hono;
30
+ } & {
31
+ methods: ["get", "post", "put", "delete", "head", "options", "patch", "all"];
32
+ };
33
+ export declare class Hono extends Hono_base {
34
+ readonly routerClass: {
22
35
  new (): Router<any>;
23
36
  };
24
- strict: boolean;
25
- router: Router<Handler>;
26
- middlewareRouters: Router<MiddlewareHandler>[];
27
- tempPath: string;
37
+ readonly strict: boolean;
38
+ private router;
39
+ private middlewareRouters;
40
+ private tempPath;
28
41
  constructor(init?: Partial<Pick<Hono, 'routerClass' | 'strict'>>);
29
42
  private notFoundHandler;
30
43
  private errorHandler;
31
- get<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
32
- get(path: string, handler: Handler<string>): Hono;
33
- post<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
34
- post(path: string, handler: Handler<string>): Hono;
35
- put<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
36
- put(path: string, handler: Handler<string>): Hono;
37
- head<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
38
- head(path: string, handler: Handler<string>): Hono;
39
- delete<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
40
- delete(path: string, handler: Handler<string>): Hono;
41
- options<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
42
- options(path: string, handler: Handler<string>): Hono;
43
- patch<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
44
- patch(path: string, handler: Handler<string>): Hono;
45
- all<Path extends string>(path: Path, handler: Handler<ParamKeys<Path>>): Hono;
46
- all(path: string, handler: Handler<string>): Hono;
47
44
  route(path: string): Hono;
48
45
  use(path: string, middleware: MiddlewareHandler): void;
49
46
  onError(handler: ErrorHandler): Hono;
50
47
  notFound(handler: NotFoundHandler): Hono;
51
48
  private addRoute;
52
49
  private matchRoute;
53
- dispatch(request: Request, env?: Env, event?: FetchEvent): Promise<Response>;
50
+ private dispatch;
54
51
  handleEvent(event: FetchEvent): Promise<Response>;
55
52
  fetch(request: Request, env?: Env, event?: FetchEvent): Promise<Response>;
56
53
  request(input: RequestInfo, requestInit?: RequestInit): Promise<Response>;
package/dist/hono.js CHANGED
@@ -2,12 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Hono = void 0;
4
4
  const compose_1 = require("./compose");
5
- const url_1 = require("./utils/url");
6
5
  const context_1 = require("./context");
7
6
  const router_1 = require("./router");
8
7
  const trie_router_1 = require("./router/trie-router"); // Default Router
9
- class Hono {
8
+ const url_1 = require("./utils/url");
9
+ function defineDynamicClass(...methods) {
10
+ return class {
11
+ get methods() {
12
+ return methods;
13
+ }
14
+ };
15
+ }
16
+ class Hono extends defineDynamicClass('get', 'post', 'put', 'delete', 'head', 'options', 'patch', 'all') {
10
17
  constructor(init = {}) {
18
+ super();
11
19
  this.routerClass = trie_router_1.TrieRouter;
12
20
  this.strict = true; // strict routing - default is true
13
21
  this.notFoundHandler = (c) => {
@@ -15,39 +23,20 @@ class Hono {
15
23
  return c.text(message, 404);
16
24
  };
17
25
  this.errorHandler = (err, c) => {
18
- console.error(`${err.message}`);
26
+ console.error(`${err.stack || err.message}`);
19
27
  const message = 'Internal Server Error';
20
28
  return c.text(message, 500);
21
29
  };
30
+ this.methods.map((method) => {
31
+ this[method] = (path, handler) => {
32
+ return this.addRoute(method, path, handler);
33
+ };
34
+ });
22
35
  Object.assign(this, init);
23
36
  this.router = new this.routerClass();
24
37
  this.middlewareRouters = [];
25
38
  this.tempPath = null;
26
39
  }
27
- get(path, handler) {
28
- return this.addRoute('get', path, handler);
29
- }
30
- post(path, handler) {
31
- return this.addRoute('post', path, handler);
32
- }
33
- put(path, handler) {
34
- return this.addRoute('put', path, handler);
35
- }
36
- head(path, handler) {
37
- return this.addRoute('head', path, handler);
38
- }
39
- delete(path, handler) {
40
- return this.addRoute('delete', path, handler);
41
- }
42
- options(path, handler) {
43
- return this.addRoute('options', path, handler);
44
- }
45
- patch(path, handler) {
46
- return this.addRoute('patch', path, handler);
47
- }
48
- all(path, handler) {
49
- return this.addRoute('all', path, handler);
50
- }
51
40
  route(path) {
52
41
  const newHono = new Hono();
53
42
  newHono.tempPath = path;
@@ -88,29 +77,20 @@ class Hono {
88
77
  const result = await this.matchRoute(method, path);
89
78
  // Methods for Request object
90
79
  request.param = (key) => {
91
- if (result) {
80
+ if (result)
92
81
  return result.params[key];
93
- }
94
- };
95
- request.header = (name) => {
96
- return request.headers.get(name);
97
- };
98
- request.query = (key) => {
99
- const url = new URL(c.req.url);
100
- return url.searchParams.get(key);
101
82
  };
102
83
  const handler = result ? result.handler : this.notFoundHandler;
103
84
  const middleware = [];
104
85
  for (const mr of this.middlewareRouters) {
105
86
  const mwResult = mr.match(router_1.METHOD_NAME_OF_ALL, path);
106
- if (mwResult) {
87
+ if (mwResult)
107
88
  middleware.push(mwResult.handler);
108
- }
109
89
  }
110
90
  const wrappedHandler = async (context, next) => {
111
91
  const res = await handler(context);
112
92
  if (!(res instanceof Response)) {
113
- throw new TypeError('response must be a instace of Response');
93
+ throw new TypeError('response must be a instance of Response');
114
94
  }
115
95
  context.res = res;
116
96
  await next();
@@ -129,7 +109,7 @@ class Hono {
129
109
  return this.dispatch(request, env, event);
130
110
  }
131
111
  request(input, requestInit) {
132
- const req = new Request(input, requestInit);
112
+ const req = input instanceof Request ? input : new Request(input, requestInit);
133
113
  return this.dispatch(req);
134
114
  }
135
115
  fire() {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Hono } from './hono';
2
- export type { Handler, MiddlewareHandler } from './hono';
2
+ export type { Handler, MiddlewareHandler, Next } from './hono';
3
3
  export { Context } from './context';
4
4
  export type { Env } from './context';
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  export declare const basicAuth: (options: {
3
4
  username: string;
4
5
  password: string;
@@ -7,4 +8,4 @@ export declare const basicAuth: (options: {
7
8
  }, ...users: {
8
9
  username: string;
9
10
  password: string;
10
- }[]) => (ctx: Context, next: Function) => Promise<any>;
11
+ }[]) => (ctx: Context, next: Next) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
3
+ export declare const bodyParse: () => (ctx: Context, next: Next) => Promise<void>;
@@ -1,10 +1,11 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  declare global {
3
4
  interface Request {
4
5
  cookie: (name: string) => string;
5
6
  }
6
7
  }
7
- declare module '../../context' {
8
+ declare module '@/context' {
8
9
  interface Context {
9
10
  cookie: (name: string, value: string, options?: CookieOptions) => void;
10
11
  }
@@ -22,4 +23,4 @@ export declare type CookieOptions = {
22
23
  signed?: boolean;
23
24
  sameSite?: 'Strict' | 'Lax' | 'None';
24
25
  };
25
- export declare const cookie: () => (c: Context, next: Function) => Promise<void>;
26
+ export declare const cookie: () => (c: Context, next: Next) => Promise<void>;
@@ -48,7 +48,7 @@ const serialize = (name, value, opt = {}) => {
48
48
  cookie += '; Secure';
49
49
  }
50
50
  if (opt.sameSite) {
51
- cookie += `; SameSaite=${opt.sameSite}`;
51
+ cookie += `; SameSite=${opt.sameSite}`;
52
52
  }
53
53
  return cookie;
54
54
  };
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  declare type CORSOptions = {
3
4
  origin: string;
4
5
  allowMethods?: string[];
@@ -7,5 +8,5 @@ declare type CORSOptions = {
7
8
  credentials?: boolean;
8
9
  exposeHeaders?: string[];
9
10
  };
10
- export declare const cors: (options?: CORSOptions) => (c: Context, next: Function) => Promise<void>;
11
+ export declare const cors: (options?: CORSOptions) => (c: Context, next: Next) => Promise<void>;
11
12
  export {};
File without changes
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  declare type ETagOptions = {
3
4
  weak: boolean;
4
5
  };
5
- export declare const etag: (options?: ETagOptions) => (c: Context, next: Function) => Promise<void>;
6
+ export declare const etag: (options?: ETagOptions) => (c: Context, next: Next) => Promise<void>;
6
7
  export {};
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.etag = void 0;
4
- const crypto_1 = require("../../utils/crypto");
5
4
  const body_1 = require("../../utils/body");
5
+ const crypto_1 = require("../../utils/crypto");
6
6
  const etag = (options = { weak: false }) => {
7
7
  return async (c, next) => {
8
8
  const ifNoneMatch = c.req.header('If-None-Match') || c.req.header('if-none-match');
@@ -1,12 +1,14 @@
1
+ import { GraphQLError } from 'graphql';
2
+ import type { GraphQLSchema, ValidationRule, GraphQLFormattedError } from 'graphql';
1
3
  import type { Context } from '../../context';
2
- import type { GraphQLSchema, ValidationRule } from 'graphql';
4
+ import type { Next } from '../../hono';
3
5
  declare type Options = {
4
6
  schema: GraphQLSchema;
5
7
  rootValue?: unknown;
6
8
  pretty?: boolean;
7
9
  validationRules?: ReadonlyArray<ValidationRule>;
8
10
  };
9
- export declare const graphqlServer: (options: Options) => (c: Context, next: Function) => Promise<void>;
11
+ export declare const graphqlServer: (options: Options) => (c: Context, next: Next) => Promise<void>;
10
12
  export interface GraphQLParams {
11
13
  query: string | null;
12
14
  variables: {
@@ -16,10 +18,11 @@ export interface GraphQLParams {
16
18
  raw: boolean;
17
19
  }
18
20
  export declare const getGraphQLParams: (request: Request) => Promise<GraphQLParams>;
19
- export declare const errorMessages: (messages: string[]) => {
21
+ export declare const errorMessages: (messages: string[], graphqlErrors?: readonly GraphQLError[] | readonly GraphQLFormattedError[]) => {
22
+ errors: readonly GraphQLError[] | readonly GraphQLFormattedError[];
23
+ } | {
20
24
  errors: {
21
25
  message: string;
22
26
  }[];
23
27
  };
24
- export declare const graphiQLResponse: () => void;
25
28
  export {};
@@ -2,9 +2,9 @@
2
2
  // Based on the code in the `express-graphql` package.
3
3
  // https://github.com/graphql/express-graphql/blob/main/src/index.ts
4
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");
5
+ exports.errorMessages = exports.getGraphQLParams = exports.graphqlServer = void 0;
7
6
  const graphql_1 = require("graphql");
7
+ const parse_body_1 = require("../../middleware/graphql-server/parse-body");
8
8
  const graphqlServer = (options) => {
9
9
  var _a, _b;
10
10
  const schema = options.schema;
@@ -27,7 +27,8 @@ const graphqlServer = (options) => {
27
27
  }
28
28
  catch (e) {
29
29
  if (e instanceof Error) {
30
- c.res = c.json((0, exports.errorMessages)([e.message]), 400);
30
+ console.error(`${e.stack || e.message}`);
31
+ c.res = c.json((0, exports.errorMessages)([e.message], [e]), 400);
31
32
  }
32
33
  return;
33
34
  }
@@ -39,7 +40,7 @@ const graphqlServer = (options) => {
39
40
  const schemaValidationErrors = (0, graphql_1.validateSchema)(schema);
40
41
  if (schemaValidationErrors.length > 0) {
41
42
  // Return 500: Internal Server Error if invalid schema.
42
- c.res = c.json((0, exports.errorMessages)(['GraphQL schema validation error.']), 500);
43
+ c.res = c.json((0, exports.errorMessages)(['GraphQL schema validation error.'], schemaValidationErrors), 500);
43
44
  return;
44
45
  }
45
46
  let documentAST;
@@ -48,14 +49,20 @@ const graphqlServer = (options) => {
48
49
  }
49
50
  catch (syntaxError) {
50
51
  // Return 400: Bad Request if any syntax errors errors exist.
51
- c.res = c.json((0, exports.errorMessages)(['GraphQL syntax error.']), 400);
52
+ if (syntaxError instanceof Error) {
53
+ console.error(`${syntaxError.stack || syntaxError.message}`);
54
+ const e = new graphql_1.GraphQLError(syntaxError.message, {
55
+ originalError: syntaxError,
56
+ });
57
+ c.res = c.json((0, exports.errorMessages)(['GraphQL syntax error.'], [e]), 400);
58
+ }
52
59
  return;
53
60
  }
54
61
  // Validate AST, reporting any errors.
55
62
  const validationErrors = (0, graphql_1.validate)(schema, documentAST, [...graphql_1.specifiedRules, ...validationRules]);
56
63
  if (validationErrors.length > 0) {
57
64
  // Return 400: Bad Request if any validation errors exist.
58
- c.res = c.json((0, exports.errorMessages)(['GraphQL validation error.']), 400);
65
+ c.res = c.json((0, exports.errorMessages)(['GraphQL validation error.'], validationErrors), 400);
59
66
  return;
60
67
  }
61
68
  if (c.req.method === 'GET') {
@@ -85,13 +92,20 @@ const graphqlServer = (options) => {
85
92
  operationName: operationName,
86
93
  });
87
94
  }
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);
95
+ catch (contextError) {
96
+ if (contextError instanceof Error) {
97
+ console.error(`${contextError.stack || contextError.message}`);
98
+ const e = new graphql_1.GraphQLError(contextError.message, {
99
+ originalError: contextError,
100
+ nodes: documentAST,
101
+ });
102
+ // Return 400: Bad Request if any execution context errors exist.
103
+ c.res = c.json((0, exports.errorMessages)(['GraphQL execution context error.'], [e]), 400);
104
+ }
91
105
  return;
92
106
  }
93
107
  if (result.data == null) {
94
- c.res = c.json((0, exports.errorMessages)([result.errors.toString()]), 500);
108
+ c.res = c.json((0, exports.errorMessages)([result.errors.toString()], result.errors), 500);
95
109
  return;
96
110
  }
97
111
  /*
@@ -149,16 +163,19 @@ const getGraphQLParams = async (request) => {
149
163
  return params;
150
164
  };
151
165
  exports.getGraphQLParams = getGraphQLParams;
152
- const errorMessages = (messages) => {
153
- const errors = messages.map((message) => {
166
+ const errorMessages = (messages, graphqlErrors) => {
167
+ if (graphqlErrors) {
154
168
  return {
155
- message: message,
169
+ errors: graphqlErrors,
156
170
  };
157
- });
171
+ }
158
172
  return {
159
- errors: errors,
173
+ errors: messages.map((message) => {
174
+ return {
175
+ message: message,
176
+ };
177
+ }),
160
178
  };
161
179
  };
162
180
  exports.errorMessages = errorMessages;
163
- const graphiQLResponse = () => { };
164
- exports.graphiQLResponse = graphiQLResponse;
181
+ // export const graphiQLResponse = () => {}
@@ -11,6 +11,9 @@ async function parseBody(req) {
11
11
  return await req.json();
12
12
  }
13
13
  catch (e) {
14
+ if (e instanceof Error) {
15
+ console.error(`${e.stack || e.message}`);
16
+ }
14
17
  throw Error(`POST body sent invalid JSON: ${e}`);
15
18
  }
16
19
  case 'application/x-www-form-urlencoded':
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  export declare const logger: (fn?: {
3
4
  (...data: any[]): void;
4
5
  (...data: any[]): void;
5
6
  (message?: any, ...optionalParams: any[]): void;
6
- }) => (c: Context, next: Function) => Promise<void>;
7
+ }) => (c: Context, next: Next) => Promise<void>;
@@ -31,10 +31,10 @@ const colorStatus = (status = 0) => {
31
31
  };
32
32
  return out[(status / 100) | 0];
33
33
  };
34
- function log(fn, prefix, method, path, status, elasped, contentLength) {
34
+ function log(fn, prefix, method, path, status, elapsed, contentLength) {
35
35
  const out = prefix === LogPrefix.Incoming
36
36
  ? ` ${prefix} ${method} ${path}`
37
- : ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elasped} ${contentLength}`;
37
+ : ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed} ${contentLength}`;
38
38
  fn(out);
39
39
  }
40
40
  const logger = (fn = console.log) => {
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  declare type Init = {
3
4
  root: string;
4
5
  };
5
- export declare const mustache: (init?: Init) => (c: Context, next: Function) => Promise<void>;
6
+ export declare const mustache: (init?: Init) => (c: Context, next: Next) => Promise<void>;
6
7
  export {};
@@ -0,0 +1,3 @@
1
+ import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
3
+ export declare const poweredBy: () => (c: Context, next: Next) => Promise<void>;
@@ -4,7 +4,6 @@ exports.poweredBy = void 0;
4
4
  const poweredBy = () => {
5
5
  return async (c, next) => {
6
6
  await next();
7
- // await c.res.headers.append('X-Powered-By', 'Hono')
8
7
  c.res.headers.append('X-Powered-By', 'Hono');
9
8
  };
10
9
  };
@@ -0,0 +1,7 @@
1
+ import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
3
+ declare type prettyOptions = {
4
+ space: number;
5
+ };
6
+ export declare const prettyJSON: (options?: prettyOptions) => (c: Context, next: Next) => Promise<void>;
7
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prettyJSON = void 0;
4
+ const prettyJSON = (options = { space: 2 }) => {
5
+ return async (c, next) => {
6
+ const pretty = c.req.query('pretty') || c.req.query('pretty') === '' ? true : false;
7
+ c.pretty(pretty, options.space);
8
+ await next();
9
+ };
10
+ };
11
+ exports.prettyJSON = prettyJSON;
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
2
3
  declare type Options = {
3
4
  root: string;
4
5
  };
5
- export declare const serveStatic: (opt?: Options) => (c: Context, next: Function) => Promise<void>;
6
+ export declare const serveStatic: (opt?: Options) => (c: Context, next: Next) => Promise<void>;
6
7
  export {};
@@ -23,7 +23,7 @@ const serveStatic = (opt = { root: '' }) => {
23
23
  c.res = c.body(content);
24
24
  }
25
25
  else {
26
- // console.debug(`Static file: ${path} is not found`)
26
+ console.warn(`Static file: ${path} is not found`);
27
27
  }
28
28
  };
29
29
  };
@@ -1 +1 @@
1
- export { RegExpRouter } from './router';
1
+ export { RegExpRouter } from '../../router/reg-exp-router/router';
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegExpRouter = void 0;
4
- var router_1 = require("./router");
4
+ var router_1 = require("../../router/reg-exp-router/router");
5
5
  Object.defineProperty(exports, "RegExpRouter", { enumerable: true, get: function () { return router_1.RegExpRouter; } });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegExpRouter = void 0;
4
4
  const router_1 = require("../../router");
5
- const trie_1 = require("./trie");
5
+ const trie_1 = require("../../router/reg-exp-router/trie");
6
6
  const regExpMatchAll = new RegExp('');
7
7
  const emptyParam = {};
8
8
  class RegExpRouter extends router_1.Router {
@@ -1,6 +1,6 @@
1
- import type { ParamMap, Context } from './node';
2
- import { Node } from './node';
3
- export type { ParamMap } from './node';
1
+ import type { ParamMap, Context } from '../../router/reg-exp-router/node';
2
+ import { Node } from '../../router/reg-exp-router/node';
3
+ export type { ParamMap } from '../../router/reg-exp-router/node';
4
4
  export declare type ReplacementMap = number[];
5
5
  export declare class Trie {
6
6
  context: Context;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Trie = void 0;
4
- const node_1 = require("./node");
4
+ const node_1 = require("../../router/reg-exp-router/node");
5
5
  class Trie {
6
6
  constructor() {
7
7
  this.context = { varIndex: 0 };
@@ -1 +1 @@
1
- export { TrieRouter } from './router';
1
+ export { TrieRouter } from '../../router/trie-router/router';
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TrieRouter = void 0;
4
- var router_1 = require("./router");
4
+ var router_1 = require("../../router/trie-router/router");
5
5
  Object.defineProperty(exports, "TrieRouter", { enumerable: true, get: function () { return router_1.TrieRouter; } });
@@ -1,5 +1,5 @@
1
- import type { Pattern } from '../../utils/url';
2
1
  import { Result } from '../../router';
2
+ import type { Pattern } from '../../utils/url';
3
3
  export declare class Node<T> {
4
4
  method: Record<string, T>;
5
5
  handler: T;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Node = void 0;
4
- const url_1 = require("../../utils/url");
5
4
  const router_1 = require("../../router");
5
+ const url_1 = require("../../utils/url");
6
6
  const noRoute = () => {
7
7
  return null;
8
8
  };
@@ -1,6 +1,6 @@
1
1
  import { Router } from '../../router';
2
2
  import type { Result } from '../../router';
3
- import { Node } from './node';
3
+ import { Node } from '../../router/trie-router/node';
4
4
  export declare class TrieRouter<T> extends Router<T> {
5
5
  node: Node<T>;
6
6
  constructor();
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TrieRouter = void 0;
4
4
  const router_1 = require("../../router");
5
- const node_1 = require("./node");
5
+ const node_1 = require("../../router/trie-router/node");
6
6
  class TrieRouter extends router_1.Router {
7
7
  constructor() {
8
8
  super();
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.timingSafeEqual = exports.equal = void 0;
4
- const crypto_1 = require("./crypto");
4
+ const crypto_1 = require("../utils/crypto");
5
5
  const equal = (a, b) => {
6
6
  if (a === b) {
7
7
  return true;
@@ -6,6 +6,6 @@ declare type Data = string | object | boolean;
6
6
  export declare const sha256: (data: Data) => Promise<string>;
7
7
  export declare const sha1: (data: Data) => Promise<string>;
8
8
  export declare const createHash: (data: Data, algorithm: Algorithm) => Promise<string>;
9
- export declare const encodeBase64: (str: string) => any;
10
- export declare const decodeBase64: (str: string) => any;
9
+ export declare const encodeBase64: (str: string) => string;
10
+ export declare const decodeBase64: (str: string) => string;
11
11
  export {};
@@ -35,6 +35,9 @@ const createHash = async (data, algorithm) => {
35
35
  };
36
36
  exports.createHash = createHash;
37
37
  const encodeBase64 = (str) => {
38
+ if (str === null) {
39
+ throw new TypeError('1st argument of "encodeBase64" should not be null.');
40
+ }
38
41
  try {
39
42
  const encoder = new TextEncoder();
40
43
  const bytes = encoder.encode(str);
@@ -57,6 +60,9 @@ const encodeBase64 = (str) => {
57
60
  };
58
61
  exports.encodeBase64 = encodeBase64;
59
62
  const decodeBase64 = (str) => {
63
+ if (str === null) {
64
+ throw new TypeError('1st argument of "decodeBase64" should not be null.');
65
+ }
60
66
  try {
61
67
  const text = atob(str);
62
68
  const length = text.length;
@@ -1 +1,2 @@
1
- export declare const getStatusText: (statusNumber: number) => string;
1
+ export declare const getStatusText: (statusCode: StatusCode) => string;
2
+ export declare type StatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 444 | 449 | 450 | 451 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 598 | 599;
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStatusText = void 0;
4
- const getStatusText = (statusNumber) => {
5
- const text = statuses[statusNumber];
4
+ const getStatusText = (statusCode) => {
5
+ const text = statuses[statusCode];
6
6
  return text;
7
7
  };
8
8
  exports.getStatusText = getStatusText;
9
9
  const statuses = {
10
+ 100: 'Continue',
11
+ 101: 'Switching Protocols',
12
+ 102: 'Processing',
13
+ 103: 'Early Hints',
10
14
  200: 'OK',
11
15
  201: 'Created',
12
16
  202: 'Accepted',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "0.5.8",
4
- "description": "[炎] Ultrafast web framework for Cloudflare Workers.",
3
+ "version": "1.0.0",
4
+ "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
@@ -9,60 +9,63 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "test": "jest",
12
- "lint": "eslint --ext js,ts src .eslintrc.js && prettier --check src",
13
- "build": "rimraf dist && tsc",
14
- "watch": "tsc -w",
12
+ "lint": "eslint --ext js,ts src .eslintrc.js",
13
+ "lint:fix": "eslint --ext js,ts src .eslintrc.js --fix",
14
+ "build": "rimraf dist && tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
15
+ "watch": "tsc -w --project tsconfig.build.json & tsc-alias -w -p tsconfig.build.json",
15
16
  "prepublishOnly": "yarn build"
16
17
  },
17
18
  "exports": {
18
19
  ".": "./dist/index.js",
19
- "./basic-auth": "./dist/middleware/basic-auth/basic-auth.js",
20
- "./body-parse": "./dist/middleware/body-parse/body-parse.js",
21
- "./cookie": "./dist/middleware/cookie/cookie.js",
22
- "./cors": "./dist/middleware/cors/cors.js",
23
- "./etag": "./dist/middleware/etag/etag.js",
24
- "./graphql-server": "./dist/middleware/graphql-server/graphql-server.js",
25
- "./logger": "./dist/middleware/logger/logger.js",
26
- "./mustache": "./dist/middleware/mustache/mustache.js",
27
- "./powered-by": "./dist/middleware/powered-by/powered-by.js",
28
- "./serve-static": "./dist/middleware/serve-static/serve-static.js",
29
- "./router/trie-router": "./dist/router/trie-router/router.js",
20
+ "./basic-auth": "./dist/middleware/basic-auth/index.js",
21
+ "./body-parse": "./dist/middleware/body-parse/index.js",
22
+ "./cookie": "./dist/middleware/cookie/index.js",
23
+ "./cors": "./dist/middleware/cors/index.js",
24
+ "./etag": "./dist/middleware/etag/index.js",
25
+ "./graphql-server": "./dist/middleware/graphql-server/index.js",
26
+ "./logger": "./dist/middleware/logger/index.js",
27
+ "./mustache": "./dist/middleware/mustache/index.js",
28
+ "./powered-by": "./dist/middleware/powered-by/index.js",
29
+ "./pretty-json": "./dist/middleware/pretty-json/index.js",
30
+ "./serve-static": "./dist/middleware/serve-static/index.js",
31
+ "./router/trie-router": "./dist/router/trie-router/index.js",
30
32
  "./router/reg-exp-router": "./dist/router/reg-exp-router/index.js",
31
- "./utils/cloudflare": "./dist/utils/cloudflare.js",
32
- "./utils/crypto": "./dist/utils/crypto.js",
33
- "./utils/mime": "./dist/utils/mime.js"
33
+ "./utils/*": "./dist/utils/*.js"
34
34
  },
35
35
  "typesVersions": {
36
36
  "*": {
37
37
  "basic-auth": [
38
- "./dist/middleware/basic-auth/basic-auth.d.ts"
38
+ "./dist/middleware/basic-auth"
39
39
  ],
40
40
  "body-parse": [
41
- "./dist/middleware/body-parse/body-parse.d.ts"
41
+ "./dist/middleware/body-parse"
42
42
  ],
43
43
  "cookie": [
44
- "./dist/middleware/cookie/cookie.d.ts"
44
+ "./dist/middleware/cookie"
45
45
  ],
46
46
  "cors": [
47
- "./dist/middleware/cors/cors.d.ts"
47
+ "./dist/middleware/cors"
48
48
  ],
49
49
  "etag": [
50
- "./dist/middleware/etag/etag.d.ts"
50
+ "./dist/middleware/etag"
51
51
  ],
52
52
  "graphql-server": [
53
- "./dist/middleware/graphql-server/graphql-server.d.ts"
53
+ "./dist/middleware/graphql-server"
54
54
  ],
55
55
  "logger": [
56
- "./dist/middleware/logger/logger.d.ts"
56
+ "./dist/middleware/logger"
57
57
  ],
58
58
  "mustache": [
59
- "./dist/middleware/mustache/mustache.d.ts"
59
+ "./dist/middleware/mustache"
60
60
  ],
61
61
  "powered-by": [
62
- "./dist/middleware/powered-by/powered-by.d.ts"
62
+ "./dist/middleware/powered-by"
63
+ ],
64
+ "pretty-json": [
65
+ "./dist/middleware/pretty-json"
63
66
  ],
64
67
  "serve-static": [
65
- "./dist/middleware/serve-static/serve-static.d.ts"
68
+ "./dist/middleware/serve-static"
66
69
  ],
67
70
  "router/trie-router": [
68
71
  "./dist/router/trie-router/router.d.ts"
@@ -70,14 +73,8 @@
70
73
  "router/reg-exp-router": [
71
74
  "./dist/router/reg-exp-router/router.d.ts"
72
75
  ],
73
- "utils/cloudflare": [
74
- "./dist/utils/cloudflare.d.ts"
75
- ],
76
- "utils/crypto": [
77
- "./dist/utils/crypto.d.ts"
78
- ],
79
- "utils/mime": [
80
- "./dist/utils/mime.d.ts"
76
+ "utils/*": [
77
+ "./dist/utils/*"
81
78
  ]
82
79
  }
83
80
  },
@@ -126,6 +123,7 @@
126
123
  "prettier-plugin-md-nocjsp": "^1.2.0",
127
124
  "rimraf": "^3.0.2",
128
125
  "ts-jest": "^27.1.2",
126
+ "tsc-alias": "^1.6.6",
129
127
  "typescript": "^4.5.5"
130
128
  },
131
129
  "engines": {
@@ -1,2 +0,0 @@
1
- import type { Context } from '../../context';
2
- export declare const bodyParse: () => (ctx: Context, next: Function) => Promise<void>;
@@ -1,2 +0,0 @@
1
- import type { Context } from '../../context';
2
- export declare const poweredBy: () => (c: Context, next: Function) => Promise<void>;