| import type { MustacheOptions } from './mustache'; | ||
| declare const module: (options?: MustacheOptions) => import("../../hono").Handler<string, import("../../context").Env>; | ||
| export { module as mustache }; |
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| // For ES module mode | ||
| import manifest from '__STATIC_CONTENT_MANIFEST'; | ||
| import { mustache } from './mustache'; | ||
| const module = (options = { root: '' }) => { | ||
| return mustache({ | ||
| root: options.root, | ||
| manifest: options.manifest ? options.manifest : manifest, | ||
| }); | ||
| }; | ||
| export { module as mustache }; |
| /// <reference types="@cloudflare/workers-types" /> | ||
| import type { Handler } from '../../hono'; | ||
| export declare type MustacheOptions = { | ||
| root: string; | ||
| manifest?: object | string; | ||
| namespace?: KVNamespace; | ||
| }; | ||
| export declare const mustache: (init?: MustacheOptions) => Handler; |
| import { bufferToString } from '../../utils/buffer'; | ||
| import { getContentFromKVAsset, getKVFilePath } from '../../utils/cloudflare'; | ||
| const EXTENSION = '.mustache'; | ||
| const DEFAULT_DOCUMENT = 'index.mustache'; | ||
| export const mustache = (init = { root: '' }) => { | ||
| const { root } = init; | ||
| return async (c, next) => { | ||
| let Mustache; | ||
| try { | ||
| Mustache = require('mustache'); | ||
| } | ||
| catch { | ||
| throw new Error('If you want to use Mustache Middleware, install "mustache" package first.'); | ||
| } | ||
| c.render = async (filename, params = {}, options) => { | ||
| const path = getKVFilePath({ | ||
| filename: `${filename}${EXTENSION}`, | ||
| root: root, | ||
| defaultDocument: DEFAULT_DOCUMENT, | ||
| }); | ||
| const kvAssetOptions = { | ||
| manifest: init.manifest, | ||
| namespace: init.namespace ? init.namespace : c.env ? c.env.__STATIC_CONTENT : undefined, | ||
| }; | ||
| const buffer = await getContentFromKVAsset(path, kvAssetOptions); | ||
| if (!buffer) { | ||
| throw new Error(`Template "${path}" is not found or blank.`); | ||
| } | ||
| const content = bufferToString(buffer); | ||
| const partialArgs = {}; | ||
| if (options) { | ||
| const partials = options; | ||
| for (const key of Object.keys(partials)) { | ||
| const partialPath = getKVFilePath({ | ||
| filename: `${partials[key]}${EXTENSION}`, | ||
| root: root, | ||
| defaultDocument: DEFAULT_DOCUMENT, | ||
| }); | ||
| const partialBuffer = await getContentFromKVAsset(partialPath, kvAssetOptions); | ||
| if (!partialBuffer) { | ||
| throw new Error(`Partial Template "${partialPath}" is not found or blank.`); | ||
| } | ||
| partialArgs[key] = bufferToString(partialBuffer); | ||
| } | ||
| } | ||
| const output = Mustache.render(content, params, partialArgs); | ||
| return c.html(output); | ||
| }; | ||
| await next(); | ||
| }; | ||
| }; |
| import type { ServeStaticOptions } from './serve-static'; | ||
| declare const module: (options?: ServeStaticOptions) => import("../../hono").Handler<string, import("../../context").Env>; | ||
| export { module as serveStatic }; |
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| // For ES module mode | ||
| import manifest from '__STATIC_CONTENT_MANIFEST'; | ||
| import { serveStatic } from './serve-static'; | ||
| const module = (options = { root: '' }) => { | ||
| return serveStatic({ | ||
| root: options.root, | ||
| manifest: options.manifest ? options.manifest : manifest, | ||
| }); | ||
| }; | ||
| export { module as serveStatic }; |
| /// <reference types="@cloudflare/workers-types" /> | ||
| import type { Handler } from '../../hono'; | ||
| export declare type ServeStaticOptions = { | ||
| root: string; | ||
| manifest?: object | string; | ||
| namespace?: KVNamespace; | ||
| }; | ||
| export declare const serveStatic: (options?: ServeStaticOptions) => Handler; |
| import { getContentFromKVAsset, getKVFilePath } from '../../utils/cloudflare'; | ||
| import { getMimeType } from '../../utils/mime'; | ||
| const DEFAULT_DOCUMENT = 'index.html'; | ||
| // This middleware is available only on Cloudflare Workers. | ||
| export const serveStatic = (options = { root: '' }) => { | ||
| return async (c, next) => { | ||
| // Do nothing if Response is already set | ||
| if (c.res) { | ||
| await next(); | ||
| } | ||
| const url = new URL(c.req.url); | ||
| const path = getKVFilePath({ | ||
| filename: url.pathname, | ||
| root: options.root, | ||
| defaultDocument: DEFAULT_DOCUMENT, | ||
| }); | ||
| const content = await getContentFromKVAsset(path, { | ||
| manifest: options.manifest, | ||
| namespace: options.namespace ? options.namespace : c.env ? c.env.__STATIC_CONTENT : undefined, | ||
| }); | ||
| if (content) { | ||
| const mimeType = getMimeType(path); | ||
| if (mimeType) { | ||
| c.header('Content-Type', mimeType); | ||
| } | ||
| // Return Response object | ||
| return c.body(content); | ||
| } | ||
| else { | ||
| console.warn(`Static file: ${path} is not found`); | ||
| await next(); | ||
| } | ||
| }; | ||
| }; |
+5
-9
@@ -1,7 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.compose = void 0; | ||
| const context_1 = require("./context"); | ||
| import { Context } from './context'; | ||
| // Based on the code in the MIT licensed `koa-compose` package. | ||
| const compose = (middleware, onError, onNotFound) => { | ||
| export const compose = (middleware, onError, onNotFound) => { | ||
| return async (context, next) => { | ||
@@ -19,3 +16,3 @@ let index = -1; | ||
| if (handler === undefined) { | ||
| if (context instanceof context_1.Context && context.res === undefined) { | ||
| if (context instanceof Context && context.res === undefined) { | ||
| context.res = onNotFound(context); | ||
@@ -28,3 +25,3 @@ } | ||
| // If handler return Response like `return c.text('foo')` | ||
| if (res && context instanceof context_1.Context) { | ||
| if (res && context instanceof Context) { | ||
| context.res = res; | ||
@@ -36,3 +33,3 @@ dispatch(i + 1); // <--- Call next() | ||
| .catch((err) => { | ||
| if (onError && context instanceof context_1.Context) { | ||
| if (onError && context instanceof Context) { | ||
| if (err instanceof Error) { | ||
@@ -50,2 +47,1 @@ context.res = onError(err, context); | ||
| }; | ||
| exports.compose = compose; |
+7
-11
@@ -1,7 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Context = void 0; | ||
| const http_status_1 = require("./utils/http-status"); | ||
| const url_1 = require("./utils/url"); | ||
| class Context { | ||
| import { getStatusText } from './utils/http-status'; | ||
| import { isAbsoluteURL } from './utils/url'; | ||
| export class Context { | ||
| constructor(req, opts) { | ||
@@ -54,3 +51,3 @@ this.res = undefined; | ||
| this._status = status; | ||
| this._statusText = (0, http_status_1.getStatusText)(status); | ||
| this._statusText = getStatusText(status); | ||
| } | ||
@@ -70,4 +67,4 @@ set(key, value) { | ||
| init.statusText = | ||
| init.statusText || this._statusText || (0, http_status_1.getStatusText)(init.status); | ||
| init.headers = Object.assign(Object.assign({}, this._headers), init.headers); | ||
| init.statusText || this._statusText || getStatusText(init.status); | ||
| init.headers = { ...this._headers, ...init.headers }; | ||
| return new Response(data, init); | ||
@@ -109,3 +106,3 @@ } | ||
| } | ||
| if (!(0, url_1.isAbsoluteURL)(location)) { | ||
| if (!isAbsoluteURL(location)) { | ||
| const url = new URL(this.req.url); | ||
@@ -123,2 +120,1 @@ url.pathname = location; | ||
| } | ||
| exports.Context = Context; |
+14
-18
@@ -1,10 +0,7 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Hono = void 0; | ||
| const compose_1 = require("./compose"); | ||
| const context_1 = require("./context"); | ||
| const router_1 = require("./router"); | ||
| const router_2 = require("./router"); | ||
| const trie_router_1 = require("./router/trie-router"); // Default Router | ||
| const url_1 = require("./utils/url"); | ||
| import { compose } from './compose'; | ||
| import { Context } from './context'; | ||
| import { METHOD_NAME_ALL } from './router'; | ||
| import { METHOD_NAME_ALL_LOWERCASE } from './router'; | ||
| import { TrieRouter } from './router/trie-router'; // Default Router | ||
| import { getPathFromURL, mergePath } from './utils/url'; | ||
| const methods = ['get', 'post', 'put', 'delete', 'head', 'options', 'patch']; | ||
@@ -15,6 +12,6 @@ function defineDynamicClass() { | ||
| } | ||
| class Hono extends defineDynamicClass() { | ||
| export class Hono extends defineDynamicClass() { | ||
| constructor(init = {}) { | ||
| super(); | ||
| this.routerClass = trie_router_1.TrieRouter; | ||
| this.routerClass = TrieRouter; | ||
| this.strict = true; // strict routing - default is true | ||
@@ -32,3 +29,3 @@ this.path = '/'; | ||
| }; | ||
| const allMethods = [...methods, router_2.METHOD_NAME_ALL_LOWERCASE]; | ||
| const allMethods = [...methods, METHOD_NAME_ALL_LOWERCASE]; | ||
| allMethods.map((method) => { | ||
@@ -72,3 +69,3 @@ this[method] = (args1, ...args) => { | ||
| handlers.map((handler) => { | ||
| this.addRoute(router_1.METHOD_NAME_ALL, this.path, handler); | ||
| this.addRoute(METHOD_NAME_ALL, this.path, handler); | ||
| }); | ||
@@ -88,3 +85,3 @@ return this; | ||
| if (this._tempPath) { | ||
| path = (0, url_1.mergePath)(this._tempPath, path); | ||
| path = mergePath(this._tempPath, path); | ||
| } | ||
@@ -99,3 +96,3 @@ this._router.add(method, path, handler); | ||
| async dispatch(request, event, env) { | ||
| const path = (0, url_1.getPathFromURL)(request.url, { strict: this.strict }); | ||
| const path = getPathFromURL(request.url, { strict: this.strict }); | ||
| const method = request.method; | ||
@@ -114,5 +111,5 @@ const result = await this.matchRoute(method, path); | ||
| const handlers = result ? result.handlers : [this.notFoundHandler]; | ||
| const c = new context_1.Context(request, { env: env, event: event, res: undefined }); | ||
| const c = new Context(request, { env: env, event: event, res: undefined }); | ||
| c.notFound = () => this.notFoundHandler(c); | ||
| const composed = (0, compose_1.compose)(handlers, this.errorHandler, this.notFoundHandler); | ||
| const composed = compose(handlers, this.errorHandler, this.notFoundHandler); | ||
| let context; | ||
@@ -147,2 +144,1 @@ try { | ||
| } | ||
| exports.Hono = Hono; |
@@ -1,7 +0,1 @@ | ||
| import type { Context } from '../../context'; | ||
| import type { Next } from '../../hono'; | ||
| declare type Init = { | ||
| root: string; | ||
| }; | ||
| export declare const mustache: (init?: Init) => (c: Context, next: Next) => Promise<void>; | ||
| export {}; | ||
| export { mustache } from './mustache'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mustache = void 0; | ||
| const buffer_1 = require("../../utils/buffer"); | ||
| const cloudflare_1 = require("../../utils/cloudflare"); | ||
| const EXTENSION = '.mustache'; | ||
| const DEFAULT_DOCUMENT = 'index.mustache'; | ||
| const mustache = (init = { root: '' }) => { | ||
| const { root } = init; | ||
| return async (c, next) => { | ||
| let Mustache; | ||
| try { | ||
| Mustache = require('mustache'); | ||
| } | ||
| catch (_a) { | ||
| throw new Error('If you want to use Mustache Middleware, install "mustache" package first.'); | ||
| } | ||
| c.render = async (filename, params = {}, options) => { | ||
| const path = (0, cloudflare_1.getKVFilePath)({ | ||
| filename: `${filename}${EXTENSION}`, | ||
| root: root, | ||
| defaultDocument: DEFAULT_DOCUMENT, | ||
| }); | ||
| const buffer = await (0, cloudflare_1.getContentFromKVAsset)(path); | ||
| if (!buffer) { | ||
| throw new Error(`Template "${path}" is not found or blank.`); | ||
| } | ||
| const content = (0, buffer_1.bufferToString)(buffer); | ||
| const partialArgs = {}; | ||
| if (options) { | ||
| const partials = options; | ||
| for (const key of Object.keys(partials)) { | ||
| const partialPath = (0, cloudflare_1.getKVFilePath)({ | ||
| filename: `${partials[key]}${EXTENSION}`, | ||
| root: root, | ||
| defaultDocument: DEFAULT_DOCUMENT, | ||
| }); | ||
| const partialBuffer = await (0, cloudflare_1.getContentFromKVAsset)(partialPath); | ||
| if (!partialBuffer) { | ||
| throw new Error(`Partial Template "${partialPath}" is not found or blank.`); | ||
| } | ||
| partialArgs[key] = (0, buffer_1.bufferToString)(partialBuffer); | ||
| } | ||
| } | ||
| const output = Mustache.render(content, params, partialArgs); | ||
| return c.html(output); | ||
| }; | ||
| await next(); | ||
| }; | ||
| }; | ||
| exports.mustache = mustache; | ||
| var mustache_1 = require("./mustache"); | ||
| Object.defineProperty(exports, "mustache", { enumerable: true, get: function () { return mustache_1.mustache; } }); |
@@ -1,7 +0,1 @@ | ||
| import type { Context } from '../../context'; | ||
| import type { Next } from '../../hono'; | ||
| declare type Options = { | ||
| root: string; | ||
| }; | ||
| export declare const serveStatic: (opt?: Options) => (c: Context, next: Next) => Promise<Response>; | ||
| export {}; | ||
| export { serveStatic } from './serve-static'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.serveStatic = void 0; | ||
| const cloudflare_1 = require("../../utils/cloudflare"); | ||
| const mime_1 = require("../../utils/mime"); | ||
| const DEFAULT_DOCUMENT = 'index.html'; | ||
| // This middleware is available only on Cloudflare Workers. | ||
| const serveStatic = (opt = { root: '' }) => { | ||
| return async (c, next) => { | ||
| // Do nothing if Response is already set | ||
| if (c.res) { | ||
| await next(); | ||
| } | ||
| const url = new URL(c.req.url); | ||
| const path = (0, cloudflare_1.getKVFilePath)({ | ||
| filename: url.pathname, | ||
| root: opt.root, | ||
| defaultDocument: DEFAULT_DOCUMENT, | ||
| }); | ||
| const content = await (0, cloudflare_1.getContentFromKVAsset)(path); | ||
| if (content) { | ||
| const mimeType = (0, mime_1.getMimeType)(path); | ||
| if (mimeType) { | ||
| c.header('Content-Type', mimeType); | ||
| } | ||
| // Return Response object | ||
| return c.body(content); | ||
| } | ||
| else { | ||
| console.warn(`Static file: ${path} is not found`); | ||
| await next(); | ||
| } | ||
| }; | ||
| }; | ||
| exports.serveStatic = serveStatic; | ||
| var serve_static_1 = require("./serve-static"); | ||
| Object.defineProperty(exports, "serveStatic", { enumerable: true, get: function () { return serve_static_1.serveStatic; } }); |
+4
-9
@@ -1,10 +0,6 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Result = exports.Router = exports.METHOD_NAME_ALL_LOWERCASE = exports.METHOD_NAME_ALL = void 0; | ||
| exports.METHOD_NAME_ALL = 'ALL'; | ||
| exports.METHOD_NAME_ALL_LOWERCASE = 'all'; | ||
| class Router { | ||
| export const METHOD_NAME_ALL = 'ALL'; | ||
| export const METHOD_NAME_ALL_LOWERCASE = 'all'; | ||
| export class Router { | ||
| } | ||
| exports.Router = Router; | ||
| class Result { | ||
| export class Result { | ||
| constructor(handlers, params) { | ||
@@ -15,2 +11,1 @@ this.handlers = handlers; | ||
| } | ||
| exports.Result = Result; |
@@ -1,5 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.TrieRouter = void 0; | ||
| var router_1 = require("./router"); | ||
| Object.defineProperty(exports, "TrieRouter", { enumerable: true, get: function () { return router_1.TrieRouter; } }); | ||
| export { TrieRouter } from './router'; |
@@ -1,6 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Node = void 0; | ||
| const router_1 = require("../../router"); | ||
| const url_1 = require("../../utils/url"); | ||
| import { Result, METHOD_NAME_ALL } from '../../router'; | ||
| import { splitPath, getPattern } from '../../utils/url'; | ||
| function findParam(node, name) { | ||
@@ -20,3 +17,3 @@ for (let i = 0, len = node.patterns.length; i < len; i++) { | ||
| } | ||
| class Node { | ||
| export class Node { | ||
| constructor(method, handler, children) { | ||
@@ -35,3 +32,3 @@ this.children = children || {}; | ||
| let curNode = this; | ||
| const parts = (0, url_1.splitPath)(path); | ||
| const parts = splitPath(path); | ||
| const parentPatterns = []; | ||
@@ -49,3 +46,3 @@ const errorMessage = (name) => { | ||
| curNode.children[p] = new Node(); | ||
| const pattern = (0, url_1.getPattern)(p); | ||
| const pattern = getPattern(p); | ||
| if (pattern) { | ||
@@ -84,3 +81,3 @@ if (typeof pattern === 'object') { | ||
| } | ||
| handler = m[router_1.METHOD_NAME_ALL]; | ||
| handler = m[METHOD_NAME_ALL]; | ||
| if (handler !== undefined) { | ||
@@ -149,3 +146,3 @@ handlers.push(handler); | ||
| let curNodes = [curNode]; | ||
| const parts = (0, url_1.splitPath)(path); | ||
| const parts = splitPath(path); | ||
| for (let i = 0, len = parts.length; i < len; i++) { | ||
@@ -168,5 +165,4 @@ const p = parts[i]; | ||
| return null; | ||
| return new router_1.Result(handlers, params); | ||
| return new Result(handlers, params); | ||
| } | ||
| } | ||
| exports.Node = Node; |
@@ -1,10 +0,7 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.TrieRouter = void 0; | ||
| const router_1 = require("../../router"); | ||
| const node_1 = require("./node"); | ||
| class TrieRouter extends router_1.Router { | ||
| import { Router } from '../../router'; | ||
| import { Node } from './node'; | ||
| export class TrieRouter extends Router { | ||
| constructor() { | ||
| super(); | ||
| this.node = new node_1.Node(); | ||
| this.node = new Node(); | ||
| } | ||
@@ -18,2 +15,1 @@ add(method, path, handler) { | ||
| } | ||
| exports.TrieRouter = TrieRouter; |
+5
-11
@@ -1,6 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.bufferToString = exports.timingSafeEqual = exports.equal = void 0; | ||
| const crypto_1 = require("./crypto"); | ||
| const equal = (a, b) => { | ||
| import { sha256 } from './crypto'; | ||
| export const equal = (a, b) => { | ||
| if (a === b) { | ||
@@ -22,6 +19,5 @@ return true; | ||
| }; | ||
| exports.equal = equal; | ||
| const timingSafeEqual = async (a, b, hashFunction) => { | ||
| export const timingSafeEqual = async (a, b, hashFunction) => { | ||
| if (!hashFunction) { | ||
| hashFunction = crypto_1.sha256; | ||
| hashFunction = sha256; | ||
| } | ||
@@ -32,4 +28,3 @@ const sa = await hashFunction(a); | ||
| }; | ||
| exports.timingSafeEqual = timingSafeEqual; | ||
| const bufferToString = (buffer) => { | ||
| export const bufferToString = (buffer) => { | ||
| if (buffer instanceof ArrayBuffer) { | ||
@@ -41,2 +36,1 @@ const enc = new TextDecoder('utf-8'); | ||
| }; | ||
| exports.bufferToString = bufferToString; |
@@ -1,3 +0,8 @@ | ||
| export declare const getContentFromKVAsset: (path: string) => Promise<ArrayBuffer>; | ||
| declare type Options = { | ||
| /// <reference types="@cloudflare/workers-types" /> | ||
| export declare type KVAssetOptions = { | ||
| manifest?: object | string; | ||
| namespace?: KVNamespace; | ||
| }; | ||
| export declare const getContentFromKVAsset: (path: string, options?: KVAssetOptions) => Promise<ArrayBuffer>; | ||
| declare type FilePathOptions = { | ||
| filename: string; | ||
@@ -7,3 +12,3 @@ root?: string; | ||
| }; | ||
| export declare const getKVFilePath: (opt: Options) => string; | ||
| export declare const getKVFilePath: (options: FilePathOptions) => string; | ||
| export {}; |
+26
-15
@@ -1,13 +0,26 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getKVFilePath = exports.getContentFromKVAsset = void 0; | ||
| const getContentFromKVAsset = async (path) => { | ||
| let ASSET_MANIFEST; | ||
| if (typeof __STATIC_CONTENT_MANIFEST === 'string') { | ||
| ASSET_MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST); | ||
| export const getContentFromKVAsset = async (path, options) => { | ||
| let ASSET_MANIFEST = {}; | ||
| if (options && options.manifest) { | ||
| if (typeof options.manifest === 'string') { | ||
| ASSET_MANIFEST = JSON.parse(options.manifest); | ||
| } | ||
| else { | ||
| ASSET_MANIFEST = options.manifest; | ||
| } | ||
| } | ||
| else { | ||
| ASSET_MANIFEST = __STATIC_CONTENT_MANIFEST; | ||
| if (typeof __STATIC_CONTENT_MANIFEST === 'string') { | ||
| ASSET_MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST); | ||
| } | ||
| else { | ||
| ASSET_MANIFEST = __STATIC_CONTENT_MANIFEST; | ||
| } | ||
| } | ||
| const ASSET_NAMESPACE = __STATIC_CONTENT; | ||
| let ASSET_NAMESPACE; | ||
| if (options && options.namespace) { | ||
| ASSET_NAMESPACE = options.namespace; | ||
| } | ||
| else { | ||
| ASSET_NAMESPACE = __STATIC_CONTENT; | ||
| } | ||
| const key = ASSET_MANIFEST[path] || path; | ||
@@ -23,7 +36,6 @@ if (!key) { | ||
| }; | ||
| exports.getContentFromKVAsset = getContentFromKVAsset; | ||
| const getKVFilePath = (opt) => { | ||
| let filename = opt.filename; | ||
| let root = opt.root || ''; | ||
| const defaultDocument = opt.defaultDocument || 'index.html'; | ||
| export const getKVFilePath = (options) => { | ||
| let filename = options.filename; | ||
| let root = options.root || ''; | ||
| const defaultDocument = options.defaultDocument || 'index.html'; | ||
| if (filename.endsWith('/')) { | ||
@@ -46,2 +58,1 @@ // /top/ => /top/index.html | ||
| }; | ||
| exports.getKVFilePath = getKVFilePath; |
+5
-11
@@ -1,17 +0,12 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.createHash = exports.sha1 = exports.sha256 = void 0; | ||
| const sha256 = async (data) => { | ||
| export const sha256 = async (data) => { | ||
| const algorithm = { name: 'SHA-256', alias: 'sha256' }; | ||
| const hash = await (0, exports.createHash)(data, algorithm); | ||
| const hash = await createHash(data, algorithm); | ||
| return hash; | ||
| }; | ||
| exports.sha256 = sha256; | ||
| const sha1 = async (data) => { | ||
| export const sha1 = async (data) => { | ||
| const algorithm = { name: 'SHA-1', alias: 'sha1' }; | ||
| const hash = await (0, exports.createHash)(data, algorithm); | ||
| const hash = await createHash(data, algorithm); | ||
| return hash; | ||
| }; | ||
| exports.sha1 = sha1; | ||
| const createHash = async (data, algorithm) => { | ||
| export const createHash = async (data, algorithm) => { | ||
| if (crypto && crypto.subtle) { | ||
@@ -36,2 +31,1 @@ const buffer = await crypto.subtle.digest({ | ||
| }; | ||
| exports.createHash = createHash; |
@@ -1,9 +0,5 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getStatusText = void 0; | ||
| const getStatusText = (statusCode) => { | ||
| export const getStatusText = (statusCode) => { | ||
| const text = statuses[statusCode]; | ||
| return text; | ||
| }; | ||
| exports.getStatusText = getStatusText; | ||
| const statuses = { | ||
@@ -10,0 +6,0 @@ 100: 'Continue', |
@@ -1,5 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getMimeType = void 0; | ||
| const getMimeType = (filename) => { | ||
| export const getMimeType = (filename) => { | ||
| const regexp = /\.([a-zA-Z0-9]+?)$/; | ||
@@ -15,3 +12,2 @@ const match = filename.match(regexp); | ||
| }; | ||
| exports.getMimeType = getMimeType; | ||
| const mimes = { | ||
@@ -18,0 +14,0 @@ aac: 'audio/aac', |
+5
-13
@@ -1,6 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mergePath = exports.isAbsoluteURL = exports.getPathFromURL = exports.getPattern = exports.splitPath = void 0; | ||
| const URL_REGEXP = /^https?:\/\/[a-zA-Z0-9\-\.:]+(\/?[^?#]*)/; | ||
| const splitPath = (path) => { | ||
| export const splitPath = (path) => { | ||
| const paths = path.split(/\//); // faster than path.split('/') | ||
@@ -12,5 +9,4 @@ if (paths[0] === '') { | ||
| }; | ||
| exports.splitPath = splitPath; | ||
| const patternCache = {}; | ||
| const getPattern = (label) => { | ||
| export const getPattern = (label) => { | ||
| // * => wildcard | ||
@@ -37,4 +33,3 @@ // :id{[0-9]+} => ([0-9]+) | ||
| }; | ||
| exports.getPattern = getPattern; | ||
| const getPathFromURL = (url, params = { strict: true }) => { | ||
| export const getPathFromURL = (url, params = { strict: true }) => { | ||
| // if strict routing is false => `/hello/hey/` and `/hello/hey` are treated the same | ||
@@ -51,4 +46,3 @@ // default is true | ||
| }; | ||
| exports.getPathFromURL = getPathFromURL; | ||
| const isAbsoluteURL = (url) => { | ||
| export const isAbsoluteURL = (url) => { | ||
| const match = url.match(URL_REGEXP); | ||
@@ -60,4 +54,3 @@ if (match) { | ||
| }; | ||
| exports.isAbsoluteURL = isAbsoluteURL; | ||
| const mergePath = (...paths) => { | ||
| export const mergePath = (...paths) => { | ||
| let p = ''; | ||
@@ -89,2 +82,1 @@ let endsWithSlash = false; | ||
| }; | ||
| exports.mergePath = mergePath; |
+11
-3
| { | ||
| "name": "hono", | ||
| "version": "1.3.3", | ||
| "version": "1.3.4", | ||
| "description": "Ultrafast web framework for Cloudflare Workers.", | ||
@@ -14,3 +14,3 @@ "main": "dist/index.js", | ||
| "lint:fix": "eslint --ext js,ts src .eslintrc.js --fix", | ||
| "build": "rimraf dist && tsc --project tsconfig.build.json", | ||
| "build": "rimraf dist && tsc --project tsconfig.build.json && tsc --project tsconfig.build.esm.json", | ||
| "watch": "tsc --project tsconfig.build.json -w", | ||
@@ -30,5 +30,7 @@ "prepublishOnly": "yarn build" | ||
| "./mustache": "./dist/middleware/mustache/index.js", | ||
| "./mustache.module": "./dist/middleware/mustache/module.mjs", | ||
| "./powered-by": "./dist/middleware/powered-by/index.js", | ||
| "./pretty-json": "./dist/middleware/pretty-json/index.js", | ||
| "./serve-static": "./dist/middleware/serve-static/index.js", | ||
| "./serve-static.module": "./dist/middleware/serve-static/module.mjs", | ||
| "./router/trie-router": "./dist/router/trie-router/index.js", | ||
@@ -68,2 +70,5 @@ "./router/reg-exp-router": "./dist/router/reg-exp-router/index.js", | ||
| ], | ||
| "mustache.module": [ | ||
| "./dist/middleware/mustache/module.d.mts" | ||
| ], | ||
| "powered-by": [ | ||
@@ -76,4 +81,7 @@ "./dist/middleware/powered-by" | ||
| "serve-static": [ | ||
| "./dist/middleware/serve-static" | ||
| "./dist/middleware/serve-static/index.d.ts" | ||
| ], | ||
| "serve-static.module": [ | ||
| "./dist/middleware/serve-static/module.d.mts" | ||
| ], | ||
| "router/trie-router": [ | ||
@@ -80,0 +88,0 @@ "./dist/router/trie-router/router.d.ts" |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
117824
0.4%83
10.67%2680
-0.15%