hono 1.3.4 → 1.3.5

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 CHANGED
@@ -510,6 +510,16 @@ test('GET /hello is ok', async () => {
510
510
  })
511
511
  ```
512
512
 
513
+ ## routerClass
514
+
515
+ The `routerClass` option specify which router is used inside. The default router is `TrieRouter`. If you want to use `RexExpRouter`, write like this:
516
+
517
+ ```ts
518
+ import { RegExpRouter } from 'hono/router/reg-exp-router'
519
+
520
+ const app = new Hono({ routerClass: RegExpRouter })
521
+ ```
522
+
513
523
  ## Cloudflare Workers with Hono
514
524
 
515
525
  Using [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/), you can develop the application locally and publish it with few commands.
@@ -584,7 +594,7 @@ import { Hono } from 'hono'
584
594
  import { cors } from 'hono/cors'
585
595
  import { basicAuth } from 'hono/basic-auth'
586
596
  import { prettyJSON } from 'hono/pretty-json'
587
- import { getPosts, getPosts, createPost } from './model'
597
+ import { getPosts, getPost, createPost, Post } from './model'
588
598
 
589
599
  const app = new Hono()
590
600
  app.get('/', (c) => c.text('Pretty Blog API'))
@@ -617,7 +627,7 @@ api.post(
617
627
  await auth(c, next)
618
628
  },
619
629
  async (c) => {
620
- const post = await c.req.json<POST>()
630
+ const post = await c.req.json<Post>()
621
631
  const ok = createPost({ post })
622
632
  return c.json({ ok })
623
633
  }
@@ -1,3 +1,4 @@
1
+ import Mustache from 'mustache';
1
2
  import { bufferToString } from '../../utils/buffer';
2
3
  import { getContentFromKVAsset, getKVFilePath } from '../../utils/cloudflare';
3
4
  const EXTENSION = '.mustache';
@@ -5,13 +6,6 @@ const DEFAULT_DOCUMENT = 'index.mustache';
5
6
  export const mustache = (init = { root: '' }) => {
6
7
  const { root } = init;
7
8
  return async (c, next) => {
8
- let Mustache;
9
- try {
10
- Mustache = require('mustache');
11
- }
12
- catch {
13
- throw new Error('If you want to use Mustache Middleware, install "mustache" package first.');
14
- }
15
9
  c.render = async (filename, params = {}, options) => {
16
10
  const path = getKVFilePath({
17
11
  filename: `${filename}${EXTENSION}`,
@@ -18,13 +18,4 @@ export const createHash = async (data, algorithm) => {
18
18
  .join('');
19
19
  return hash;
20
20
  }
21
- try {
22
- const crypto = require('crypto');
23
- const hash = crypto.createHash(algorithm.alias).update(data).digest('hex');
24
- return hash;
25
- }
26
- catch (e) {
27
- console.error(`If you want to create hash ${algorithm.name}, polyfill "crypto" module.`);
28
- throw e;
29
- }
30
21
  };
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.arrayBufferToBase64URL = exports.arrayBufferToBase64 = exports.utf8ToUint8Array = exports.decodeBase64URL = exports.encodeBase64URL = exports.decodeBase64 = exports.encodeBase64 = void 0;
27
4
  const encodeBase64 = (str) => {
@@ -35,7 +12,6 @@ const encodeBase64 = (str) => {
35
12
  }
36
13
  catch (_a) { }
37
14
  try {
38
- const { Buffer } = require('buffer');
39
15
  return Buffer.from(str).toString('base64');
40
16
  }
41
17
  catch (e) {
@@ -56,7 +32,6 @@ const decodeBase64 = (str) => {
56
32
  }
57
33
  catch (_a) { }
58
34
  try {
59
- const { Buffer } = require('buffer');
60
35
  return Buffer.from(str, 'base64').toString();
61
36
  }
62
37
  catch (e) {
@@ -93,7 +68,6 @@ const arrayBufferToBase64 = async (buf) => {
93
68
  return btoa(String.fromCharCode(...new Uint8Array(buf)));
94
69
  }
95
70
  try {
96
- const { Buffer } = await Promise.resolve().then(() => __importStar(require('buffer')));
97
71
  return Buffer.from(String.fromCharCode(...new Uint8Array(buf))).toString('base64');
98
72
  }
99
73
  catch (e) { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",