hono 1.6.2 → 2.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 (37) hide show
  1. package/README.md +22 -746
  2. package/dist/compose.d.ts +5 -1
  3. package/dist/compose.js +3 -3
  4. package/dist/context.d.ts +27 -3
  5. package/dist/context.js +8 -3
  6. package/dist/hono.d.ts +3 -3
  7. package/dist/hono.js +4 -4
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.js +2 -3
  10. package/dist/middleware/basic-auth/index.js +0 -9
  11. package/dist/middleware/compress/index.d.ts +7 -0
  12. package/dist/middleware/compress/index.js +19 -0
  13. package/dist/middleware/jsx/index.js +21 -1
  14. package/dist/middleware/jwt/index.js +3 -0
  15. package/dist/middleware/serve-static/bun.d.ts +7 -0
  16. package/dist/middleware/serve-static/bun.js +38 -0
  17. package/dist/middleware/serve-static/module.d.mts +3 -1
  18. package/dist/middleware/serve-static/serve-static.d.ts +1 -2
  19. package/dist/request.d.ts +9 -0
  20. package/dist/request.js +19 -0
  21. package/dist/utils/cookie.d.ts +13 -0
  22. package/dist/{middleware/cookie/index.js → utils/cookie.js} +3 -22
  23. package/dist/utils/jwt/jwt.js +3 -0
  24. package/package.json +13 -23
  25. package/dist/middleware/body-parse/index.d.ts +0 -8
  26. package/dist/middleware/body-parse/index.js +0 -11
  27. package/dist/middleware/cookie/index.d.ts +0 -27
  28. package/dist/middleware/graphql-server/index.d.ts +0 -28
  29. package/dist/middleware/graphql-server/index.js +0 -174
  30. package/dist/middleware/graphql-server/parse-body.d.ts +0 -1
  31. package/dist/middleware/graphql-server/parse-body.js +0 -31
  32. package/dist/middleware/mustache/index.d.ts +0 -1
  33. package/dist/middleware/mustache/index.js +0 -5
  34. package/dist/middleware/mustache/module.d.mts +0 -3
  35. package/dist/middleware/mustache/module.mjs +0 -12
  36. package/dist/middleware/mustache/mustache.d.ts +0 -14
  37. package/dist/middleware/mustache/mustache.js +0 -53
package/dist/compose.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import type { ErrorHandler, NotFoundHandler } from './hono';
2
- export declare const compose: <C>(middleware: Function[], onError?: ErrorHandler<import("./context").Env> | undefined, onNotFound?: NotFoundHandler<import("./context").Env> | undefined) => (context: C, next?: Function | undefined) => Promise<C>;
2
+ export declare const compose: <C>(middleware: Function[], onError?: ErrorHandler<{
3
+ [x: string]: any;
4
+ }> | undefined, onNotFound?: NotFoundHandler<{
5
+ [x: string]: any;
6
+ }> | undefined) => (context: C, next?: Function | undefined) => Promise<C>;
package/dist/compose.js CHANGED
@@ -16,7 +16,7 @@ const compose = (middleware, onError, onNotFound) => {
16
16
  if (i === middleware.length && next)
17
17
  handler = next;
18
18
  if (!handler) {
19
- if (context instanceof context_1.Context && context.finalized === false && onNotFound) {
19
+ if (context instanceof context_1.HonoContext && context.finalized === false && onNotFound) {
20
20
  context.res = await onNotFound(context);
21
21
  }
22
22
  return Promise.resolve(context);
@@ -24,13 +24,13 @@ const compose = (middleware, onError, onNotFound) => {
24
24
  return Promise.resolve(handler(context, () => dispatch(i + 1)))
25
25
  .then(async (res) => {
26
26
  // If handler return Response like `return c.text('foo')`
27
- if (res && context instanceof context_1.Context) {
27
+ if (res && context instanceof context_1.HonoContext) {
28
28
  context.res = res;
29
29
  }
30
30
  return context;
31
31
  })
32
32
  .catch((err) => {
33
- if (context instanceof context_1.Context && onError) {
33
+ if (context instanceof context_1.HonoContext && onError) {
34
34
  if (err instanceof Error) {
35
35
  context.res = onError(err, context);
36
36
  }
package/dist/context.d.ts CHANGED
@@ -1,16 +1,39 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
2
  import type { NotFoundHandler } from './hono';
3
+ import type { CookieOptions } from './utils/cookie';
3
4
  import type { StatusCode } from './utils/http-status';
4
5
  declare type Headers = Record<string, string>;
5
6
  export declare type Data = string | ArrayBuffer | ReadableStream;
6
- export declare type Env = Record<string, any>;
7
- export declare class Context<RequestParamKeyType extends string = string, E = Env> {
7
+ declare type Env = Record<string, any>;
8
+ export interface Context<RequestParamKeyType extends string = string, E = Env> {
8
9
  req: Request<RequestParamKeyType>;
9
10
  env: E;
10
11
  event: FetchEvent | undefined;
11
12
  executionCtx: ExecutionContext | undefined;
12
13
  finalized: boolean;
13
- private _status;
14
+ get res(): Response;
15
+ set res(_res: Response);
16
+ header: (name: string, value: string) => void;
17
+ status: (status: StatusCode) => void;
18
+ set: (key: string, value: any) => void;
19
+ get: (key: string) => any;
20
+ pretty: (prettyJSON: boolean, space?: number) => void;
21
+ newResponse: (data: Data | null, status: StatusCode, headers: Headers) => Response;
22
+ body: (data: Data | null, status?: StatusCode, headers?: Headers) => Response;
23
+ text: (text: string, status?: StatusCode, headers?: Headers) => Response;
24
+ json: <T>(object: T, status?: StatusCode, headers?: Headers) => Response;
25
+ html: (html: string, status?: StatusCode, headers?: Headers) => Response;
26
+ redirect: (location: string, status?: StatusCode) => Response;
27
+ cookie: (name: string, value: string, options?: CookieOptions) => void;
28
+ notFound: () => Response | Promise<Response>;
29
+ }
30
+ export declare class HonoContext<RequestParamKeyType extends string = string, E = Env> implements Context<RequestParamKeyType, E> {
31
+ req: Request<RequestParamKeyType>;
32
+ env: E;
33
+ event: FetchEvent | undefined;
34
+ executionCtx: ExecutionContext | undefined;
35
+ finalized: boolean;
36
+ _status: StatusCode;
14
37
  private _pretty;
15
38
  private _prettySpace;
16
39
  private _map;
@@ -31,6 +54,7 @@ export declare class Context<RequestParamKeyType extends string = string, E = En
31
54
  json<T>(object: T, status?: StatusCode, headers?: Headers): Response;
32
55
  html(html: string, status?: StatusCode, headers?: Headers): Response;
33
56
  redirect(location: string, status?: StatusCode): Response;
57
+ cookie(name: string, value: string, opt?: CookieOptions): void;
34
58
  notFound(): Response | Promise<Response>;
35
59
  }
36
60
  export {};
package/dist/context.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Context = void 0;
3
+ exports.HonoContext = void 0;
4
+ const cookie_1 = require("./utils/cookie");
4
5
  const url_1 = require("./utils/url");
5
- class Context {
6
+ class HonoContext {
6
7
  constructor(req, env = undefined, eventOrExecutionCtx = undefined, notFoundHandler = () => new Response()) {
7
8
  this._status = 200;
8
9
  this._pretty = false;
@@ -89,8 +90,12 @@ class Context {
89
90
  Location: location,
90
91
  });
91
92
  }
93
+ cookie(name, value, opt) {
94
+ const cookie = (0, cookie_1.serialize)(name, value, opt);
95
+ this.header('Set-Cookie', cookie);
96
+ }
92
97
  notFound() {
93
98
  return this.notFoundHandler(this);
94
99
  }
95
100
  }
96
- exports.Context = Context;
101
+ exports.HonoContext = HonoContext;
package/dist/hono.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import { Context } from './context';
3
- import type { Env } from './context';
2
+ import type { Context } from './context';
4
3
  import type { Router } from './router';
4
+ declare type Env = Record<string, any>;
5
5
  export declare type Handler<RequestParamKeyType extends string = string, E = Env> = (c: Context<RequestParamKeyType, E>, next: Next) => Response | Promise<Response> | Promise<void> | Promise<Response | undefined>;
6
6
  export declare type NotFoundHandler<E = Env> = (c: Context<string, E>) => Response | Promise<Response>;
7
7
  export declare type ErrorHandler<E = Env> = (err: Error, c: Context<string, E>) => Response;
@@ -48,7 +48,7 @@ export declare class Hono<E extends Env = Env, P extends string = '/'> extends H
48
48
  private matchRoute;
49
49
  private dispatch;
50
50
  handleEvent(event: FetchEvent): Promise<Response>;
51
- fetch(request: Request, env?: E, executionCtx?: ExecutionContext): Promise<Response>;
51
+ fetch: (request: Request, env?: E | undefined, executionCtx?: ExecutionContext | undefined) => Promise<Response>;
52
52
  request(input: RequestInfo, requestInit?: RequestInit): Promise<Response>;
53
53
  }
54
54
  export {};
package/dist/hono.js CHANGED
@@ -29,6 +29,9 @@ class Hono extends defineDynamicClass() {
29
29
  const message = 'Internal Server Error';
30
30
  return c.text(message, 500);
31
31
  };
32
+ this.fetch = async (request, env, executionCtx) => {
33
+ return this.dispatch(request, executionCtx, env);
34
+ };
32
35
  (0, request_1.extendRequestPrototype)();
33
36
  const allMethods = [...methods, router_1.METHOD_NAME_ALL_LOWERCASE];
34
37
  allMethods.map((method) => {
@@ -97,7 +100,7 @@ class Hono extends defineDynamicClass() {
97
100
  const result = this.matchRoute(method, path);
98
101
  request.paramData = result?.params;
99
102
  const handlers = result ? result.handlers : [this.notFoundHandler];
100
- const c = new context_1.Context(request, env, eventOrExecutionCtx, this.notFoundHandler);
103
+ const c = new context_1.HonoContext(request, env, eventOrExecutionCtx, this.notFoundHandler);
101
104
  const composed = (0, compose_1.compose)(handlers, this.errorHandler, this.notFoundHandler);
102
105
  let context;
103
106
  try {
@@ -117,9 +120,6 @@ class Hono extends defineDynamicClass() {
117
120
  async handleEvent(event) {
118
121
  return this.dispatch(event.request, event);
119
122
  }
120
- async fetch(request, env, executionCtx) {
121
- return this.dispatch(request, executionCtx, env);
122
- }
123
123
  request(input, requestInit) {
124
124
  const req = input instanceof Request ? input : new Request(input, requestInit);
125
125
  return this.dispatch(req);
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  /// <reference path="request.d.ts" />
2
2
  import { Hono } from './hono';
3
3
  export type { Handler, Next } from './hono';
4
- export { Context } from './context';
5
- export type { Env } from './context';
4
+ export type { Context } from './context';
6
5
  declare module './hono' {
7
6
  interface Hono {
8
7
  fire(): void;
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
+ // @denoify-ignore
2
3
  // eslint-disable-next-line @typescript-eslint/triple-slash-reference
3
4
  /// <reference path="./request.ts" /> Import "declare global" for the Request interface.
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.Hono = exports.Context = void 0;
6
+ exports.Hono = void 0;
6
7
  const hono_1 = require("./hono");
7
8
  Object.defineProperty(exports, "Hono", { enumerable: true, get: function () { return hono_1.Hono; } });
8
- var context_1 = require("./context");
9
- Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.Context; } });
10
9
  hono_1.Hono.prototype.fire = function () {
11
10
  addEventListener('fetch', (event) => {
12
11
  void event.respondWith(this.handleEvent(event));
@@ -6,15 +6,6 @@ const encode_1 = require("../../utils/encode");
6
6
  const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/;
7
7
  const USER_PASS_REGEXP = /^([^:]*):(.*)$/;
8
8
  const auth = (req) => {
9
- if (!req) {
10
- throw new TypeError('argument req is required');
11
- }
12
- if (typeof req !== 'object') {
13
- throw new TypeError('argument req is required to be an object');
14
- }
15
- if (!req.headers || typeof req.headers !== 'object') {
16
- throw new TypeError('argument req is required to have headers property');
17
- }
18
9
  const match = CREDENTIALS_REGEXP.exec(req.headers.get('Authorization') || '');
19
10
  if (!match) {
20
11
  return undefined;
@@ -0,0 +1,7 @@
1
+ import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
3
+ interface CompressionOptions {
4
+ encoding?: 'gzip' | 'deflate';
5
+ }
6
+ export declare const compress: (options?: CompressionOptions | undefined) => (ctx: Context, next: Next) => Promise<void>;
7
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compress = void 0;
4
+ const compress = (options) => {
5
+ return async (ctx, next) => {
6
+ await next();
7
+ const accepted = ctx.req.headers.get('Accept-Encoding');
8
+ const pattern = options?.encoding ?? /gzip|deflate/;
9
+ const match = accepted?.match(pattern);
10
+ if (!accepted || !match || !ctx.res.body) {
11
+ return;
12
+ }
13
+ const encoding = match[0];
14
+ const stream = new CompressionStream(encoding);
15
+ ctx.res = new Response(ctx.res.body.pipeThrough(stream), ctx.res.clone());
16
+ ctx.res.headers.set('Content-Encoding', encoding);
17
+ };
18
+ };
19
+ exports.compress = compress;
@@ -2,6 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Fragment = exports.memo = exports.jsx = void 0;
4
4
  const html_1 = require("../../utils/html");
5
+ const emptyTags = [
6
+ 'area',
7
+ 'base',
8
+ 'br',
9
+ 'col',
10
+ 'embed',
11
+ 'hr',
12
+ 'img',
13
+ 'input',
14
+ 'keygen',
15
+ 'link',
16
+ 'meta',
17
+ 'param',
18
+ 'source',
19
+ 'track',
20
+ 'wbr',
21
+ ];
5
22
  const jsx = (tag, props, ...children) => {
6
23
  if (typeof tag === 'function') {
7
24
  return tag.call(null, { ...props, children: children.length <= 1 ? children[0] : children });
@@ -25,6 +42,9 @@ const jsx = (tag, props, ...children) => {
25
42
  result += ` ${propsKeys[i]}="${(0, html_1.escape)(v.toString())}"`;
26
43
  }
27
44
  if (tag !== '') {
45
+ if (emptyTags.includes(tag)) {
46
+ result += '/';
47
+ }
28
48
  result += '>';
29
49
  }
30
50
  const flattenChildren = children.flat(Infinity);
@@ -40,7 +60,7 @@ const jsx = (tag, props, ...children) => {
40
60
  result += (0, html_1.escape)(child.toString());
41
61
  }
42
62
  }
43
- if (tag !== '') {
63
+ if (tag !== '' && !emptyTags.includes(tag)) {
44
64
  result += `</${tag}>`;
45
65
  }
46
66
  const escapedString = new String(result);
@@ -6,6 +6,9 @@ const jwt = (options) => {
6
6
  if (!options) {
7
7
  throw new Error('JWT auth middleware requires options for "secret');
8
8
  }
9
+ if (!crypto.subtle || !crypto.subtle.importKey) {
10
+ throw new Error('`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.');
11
+ }
9
12
  return async (ctx, next) => {
10
13
  const credentials = ctx.req.headers.get('Authorization');
11
14
  if (!credentials) {
@@ -0,0 +1,7 @@
1
+ import type { Context } from '../../context';
2
+ import type { Next } from '../../hono';
3
+ export declare type ServeStaticOptions = {
4
+ root?: string;
5
+ path?: string;
6
+ };
7
+ export declare const serveStatic: (options?: ServeStaticOptions) => (c: Context, next: Next) => Promise<Response | undefined>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serveStatic = void 0;
4
+ const filepath_1 = require("../../utils/filepath");
5
+ const mime_1 = require("../../utils/mime");
6
+ // @ts-ignore
7
+ const { file } = Bun;
8
+ const DEFAULT_DOCUMENT = 'index.html';
9
+ const serveStatic = (options = { root: '' }) => {
10
+ return async (c, next) => {
11
+ // Do nothing if Response is already set
12
+ if (c.res && c.finalized) {
13
+ await next();
14
+ }
15
+ const url = new URL(c.req.url);
16
+ let path = (0, filepath_1.getFilePath)({
17
+ filename: options.path ?? url.pathname,
18
+ root: options.root,
19
+ defaultDocument: DEFAULT_DOCUMENT,
20
+ });
21
+ path = `./${path}`;
22
+ const content = file(path);
23
+ if (content) {
24
+ const mimeType = (0, mime_1.getMimeType)(path);
25
+ if (mimeType) {
26
+ c.header('Content-Type', mimeType);
27
+ }
28
+ // Return Response object
29
+ return c.body(content);
30
+ }
31
+ else {
32
+ console.warn(`Static file: ${path} is not found`);
33
+ await next();
34
+ }
35
+ return;
36
+ };
37
+ };
38
+ exports.serveStatic = serveStatic;
@@ -1,3 +1,5 @@
1
1
  import type { ServeStaticOptions } from './serve-static';
2
- declare const module: (options?: ServeStaticOptions) => import("../../hono").Handler<string, import("../../context").Env>;
2
+ declare const module: (options?: ServeStaticOptions) => import("../../hono").Handler<string, {
3
+ [x: string]: any;
4
+ }>;
3
5
  export { module as serveStatic };
@@ -1,5 +1,4 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import type { Env } from '../../context';
3
2
  import type { Handler } from '../../hono';
4
3
  export declare type ServeStaticOptions = {
5
4
  root?: string;
@@ -7,4 +6,4 @@ export declare type ServeStaticOptions = {
7
6
  manifest?: object | string;
8
7
  namespace?: KVNamespace;
9
8
  };
10
- export declare const serveStatic: (options?: ServeStaticOptions) => Handler<string, Env>;
9
+ export declare const serveStatic: (options?: ServeStaticOptions) => Handler;
package/dist/request.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Cookie } from './utils/cookie';
1
2
  declare global {
2
3
  interface Request<ParamKeyType extends string = string> {
3
4
  param: {
@@ -17,6 +18,14 @@ declare global {
17
18
  (name: string): string;
18
19
  (): Record<string, string>;
19
20
  };
21
+ cookie: {
22
+ (name: string): string;
23
+ (): Cookie;
24
+ };
25
+ parsedBody?: Promise<any>;
26
+ parseBody: {
27
+ (): Promise<any>;
28
+ };
20
29
  }
21
30
  }
22
31
  export declare function extendRequestPrototype(): void;
package/dist/request.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extendRequestPrototype = void 0;
4
+ const body_1 = require("./utils/body");
5
+ const cookie_1 = require("./utils/cookie");
4
6
  function extendRequestPrototype() {
5
7
  if (!!Request.prototype.param) {
6
8
  // already extended
@@ -55,5 +57,22 @@ function extendRequestPrototype() {
55
57
  return result;
56
58
  }
57
59
  };
60
+ Request.prototype.cookie = function (key) {
61
+ const cookie = this.headers.get('Cookie') || '';
62
+ const obj = (0, cookie_1.parse)(cookie);
63
+ if (key) {
64
+ const value = obj[key];
65
+ return value;
66
+ }
67
+ else {
68
+ return obj;
69
+ }
70
+ };
71
+ Request.prototype.parseBody = function () {
72
+ if (!this.parsedBody) {
73
+ this.parsedBody = (0, body_1.parseBody)(this);
74
+ }
75
+ return this.parsedBody;
76
+ };
58
77
  }
59
78
  exports.extendRequestPrototype = extendRequestPrototype;
@@ -0,0 +1,13 @@
1
+ export declare type Cookie = Record<string, string>;
2
+ export declare type CookieOptions = {
3
+ domain?: string;
4
+ expires?: Date;
5
+ httpOnly?: boolean;
6
+ maxAge?: number;
7
+ path?: string;
8
+ secure?: boolean;
9
+ signed?: boolean;
10
+ sameSite?: 'Strict' | 'Lax' | 'None';
11
+ };
12
+ export declare const parse: (cookie: string) => Cookie;
13
+ export declare const serialize: (name: string, value: string, opt?: CookieOptions) => string;
@@ -1,27 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cookie = void 0;
4
- const cookie = () => {
5
- return async (c, next) => {
6
- c.req.cookie = ((name) => {
7
- const cookie = c.req.headers.get('Cookie') || '';
8
- const obj = parse(cookie);
9
- if (name) {
10
- const value = obj[name];
11
- return value;
12
- }
13
- else {
14
- return obj;
15
- }
16
- });
17
- c.cookie = (name, value, opt) => {
18
- const cookie = serialize(name, value, opt);
19
- c.header('Set-Cookie', cookie);
20
- };
21
- await next();
22
- };
23
- };
24
- exports.cookie = cookie;
3
+ exports.serialize = exports.parse = void 0;
25
4
  const parse = (cookie) => {
26
5
  const pairs = cookie.split(/;\s*/g);
27
6
  const parsedCookie = {};
@@ -31,6 +10,7 @@ const parse = (cookie) => {
31
10
  }
32
11
  return parsedCookie;
33
12
  };
13
+ exports.parse = parse;
34
14
  const serialize = (name, value, opt = {}) => {
35
15
  value = encodeURIComponent(value);
36
16
  let cookie = `${name}=${value}`;
@@ -57,3 +37,4 @@ const serialize = (name, value, opt = {}) => {
57
37
  }
58
38
  return cookie;
59
39
  };
40
+ exports.serialize = serialize;
@@ -50,6 +50,9 @@ const param = (name) => {
50
50
  }
51
51
  };
52
52
  const signing = async (data, secret, alg = types_1.AlgorithmTypes.HS256) => {
53
+ if (!crypto.subtle || !crypto.subtle.importKey) {
54
+ throw new Error('`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.');
55
+ }
53
56
  const cryptoKey = await crypto.subtle.importKey(CryptoKeyFormat.RAW, (0, encode_1.utf8ToUint8Array)(secret), param(alg), false, [CryptoKeyUsage.Sign]);
54
57
  return await crypto.subtle.sign(param(alg), cryptoKey, (0, encode_1.utf8ToUint8Array)(data));
55
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "1.6.2",
3
+ "version": "2.0.0",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,32 +9,30 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "test": "jest",
12
+ "test:deno": "deno test --allow-read deno_test",
13
+ "test:bun": "bun run ./bun_test/index.test.ts",
12
14
  "lint": "eslint --ext js,ts src .eslintrc.js",
13
15
  "lint:fix": "eslint --ext js,ts src .eslintrc.js --fix",
14
16
  "denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.ts'",
15
17
  "build": "rimraf dist && tsc --project tsconfig.build.esm.json && tsc --project tsconfig.build.json",
16
18
  "watch": "tsc --project tsconfig.build.json -w",
17
- "prerelease": "yarn denoify && yarn build",
19
+ "prerelease": "yarn denoify && yarn test:deno && yarn build",
18
20
  "release": "np"
19
21
  },
20
22
  "exports": {
21
23
  ".": "./dist/index.js",
22
24
  "./basic-auth": "./dist/middleware/basic-auth/index.js",
23
25
  "./bearer-auth": "./dist/middleware/bearer-auth/index.js",
24
- "./body-parse": "./dist/middleware/body-parse/index.js",
25
- "./cookie": "./dist/middleware/cookie/index.js",
26
26
  "./cors": "./dist/middleware/cors/index.js",
27
27
  "./etag": "./dist/middleware/etag/index.js",
28
- "./graphql-server": "./dist/middleware/graphql-server/index.js",
29
28
  "./html": "./dist/middleware/html/index.js",
30
29
  "./jsx": "./dist/middleware/jsx/index.js",
31
30
  "./jwt": "./dist/middleware/jwt/index.js",
32
31
  "./logger": "./dist/middleware/logger/index.js",
33
- "./mustache": "./dist/middleware/mustache/index.js",
34
- "./mustache.module": "./dist/middleware/mustache/module.mjs",
35
32
  "./powered-by": "./dist/middleware/powered-by/index.js",
36
33
  "./pretty-json": "./dist/middleware/pretty-json/index.js",
37
34
  "./serve-static": "./dist/middleware/serve-static/index.js",
35
+ "./serve-static.bun": "./dist/middleware/serve-static/bun.js",
38
36
  "./serve-static.module": "./dist/middleware/serve-static/module.mjs",
39
37
  "./router/trie-router": "./dist/router/trie-router/index.js",
40
38
  "./router/reg-exp-router": "./dist/router/reg-exp-router/index.js",
@@ -49,9 +47,6 @@
49
47
  "bearer-auth": [
50
48
  "./dist/middleware/bearer-auth"
51
49
  ],
52
- "body-parse": [
53
- "./dist/middleware/body-parse"
54
- ],
55
50
  "cookie": [
56
51
  "./dist/middleware/cookie"
57
52
  ],
@@ -61,9 +56,6 @@
61
56
  "etag": [
62
57
  "./dist/middleware/etag"
63
58
  ],
64
- "graphql-server": [
65
- "./dist/middleware/graphql-server"
66
- ],
67
59
  "html": [
68
60
  "./dist/middleware/html"
69
61
  ],
@@ -76,12 +68,6 @@
76
68
  "logger": [
77
69
  "./dist/middleware/logger"
78
70
  ],
79
- "mustache": [
80
- "./dist/middleware/mustache"
81
- ],
82
- "mustache.module": [
83
- "./dist/middleware/mustache/module.d.mts"
84
- ],
85
71
  "powered-by": [
86
72
  "./dist/middleware/powered-by"
87
73
  ],
@@ -91,6 +77,9 @@
91
77
  "serve-static": [
92
78
  "./dist/middleware/serve-static/index.d.ts"
93
79
  ],
80
+ "serve-static.bun": [
81
+ "./dist/middleware/serve-static/bun.d.ts"
82
+ ],
94
83
  "serve-static.module": [
95
84
  "./dist/middleware/serve-static/module.d.mts"
96
85
  ],
@@ -119,6 +108,7 @@
119
108
  },
120
109
  "homepage": "https://github.com/honojs/hono",
121
110
  "keywords": [
111
+ "hono",
122
112
  "web",
123
113
  "app",
124
114
  "http",
@@ -128,7 +118,9 @@
128
118
  "cloudflare",
129
119
  "workers",
130
120
  "fastly",
131
- "compute@edge"
121
+ "compute@edge",
122
+ "deno",
123
+ "bun"
132
124
  ],
133
125
  "devDependencies": {
134
126
  "@cloudflare/workers-types": "^3.7.1",
@@ -149,13 +141,11 @@
149
141
  "eslint-plugin-import": "^2.26.0",
150
142
  "eslint-plugin-node": "^11.1.0",
151
143
  "form-data": "^4.0.0",
152
- "graphql": "^16.4.0",
153
144
  "jest": "27.5.1",
154
- "jest-environment-miniflare": "^2.5.1",
145
+ "jest-environment-miniflare": "^2.6.0",
155
146
  "mustache": "^4.2.0",
156
147
  "np": "^7.6.2",
157
148
  "prettier": "^2.6.2",
158
- "prettier-plugin-md-nocjsp": "^1.2.0",
159
149
  "rimraf": "^3.0.2",
160
150
  "ts-jest": "^27.1.4",
161
151
  "typescript": "^4.6.3"
@@ -1,8 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { Next } from '../../hono';
3
- declare global {
4
- interface Request {
5
- parsedBody: any;
6
- }
7
- }
8
- export declare const bodyParse: () => (ctx: Context, next: Next) => Promise<void>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bodyParse = void 0;
4
- const body_1 = require("../../utils/body");
5
- const bodyParse = () => {
6
- return async (ctx, next) => {
7
- ctx.req.parsedBody = await (0, body_1.parseBody)(ctx.req);
8
- await next();
9
- };
10
- };
11
- exports.bodyParse = bodyParse;
@@ -1,27 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { Next } from '../../hono';
3
- declare global {
4
- interface Request {
5
- cookie: {
6
- (name: string): string;
7
- (): Record<string, string>;
8
- };
9
- }
10
- }
11
- declare module '../../context' {
12
- interface Context {
13
- cookie: (name: string, value: string, options?: CookieOptions) => void;
14
- }
15
- }
16
- export declare type Cookie = Record<string, string>;
17
- export declare type CookieOptions = {
18
- domain?: string;
19
- expires?: Date;
20
- httpOnly?: boolean;
21
- maxAge?: number;
22
- path?: string;
23
- secure?: boolean;
24
- signed?: boolean;
25
- sameSite?: 'Strict' | 'Lax' | 'None';
26
- };
27
- export declare const cookie: () => (c: Context, next: Next) => Promise<void>;