Comparing version 1.6.0 to 1.6.1
@@ -10,2 +10,3 @@ "use strict"; | ||
const cloudflare_1 = require("../../utils/cloudflare"); | ||
const filepath_1 = require("../../utils/filepath"); | ||
const EXTENSION = '.mustache'; | ||
@@ -17,3 +18,3 @@ const DEFAULT_DOCUMENT = 'index.mustache'; | ||
c.render = async (filename, params = {}, options) => { | ||
const path = (0, cloudflare_1.getKVFilePath)({ | ||
const path = (0, filepath_1.getFilePath)({ | ||
filename: `${filename}${EXTENSION}`, | ||
@@ -36,3 +37,3 @@ root: root, | ||
for (const key of Object.keys(partials)) { | ||
const partialPath = (0, cloudflare_1.getKVFilePath)({ | ||
const partialPath = (0, filepath_1.getFilePath)({ | ||
filename: `${partials[key]}${EXTENSION}`, | ||
@@ -39,0 +40,0 @@ root: root, |
@@ -5,2 +5,3 @@ "use strict"; | ||
const cloudflare_1 = require("../../utils/cloudflare"); | ||
const filepath_1 = require("../../utils/filepath"); | ||
const mime_1 = require("../../utils/mime"); | ||
@@ -16,3 +17,3 @@ const DEFAULT_DOCUMENT = 'index.html'; | ||
const url = new URL(c.req.url); | ||
const path = (0, cloudflare_1.getKVFilePath)({ | ||
const path = (0, filepath_1.getFilePath)({ | ||
filename: options.path ?? url.pathname, | ||
@@ -19,0 +20,0 @@ root: options.root, |
@@ -7,8 +7,1 @@ /// <reference types="@cloudflare/workers-types" /> | ||
export declare const getContentFromKVAsset: (path: string, options?: KVAssetOptions | undefined) => Promise<ArrayBuffer | null>; | ||
declare type FilePathOptions = { | ||
filename: string; | ||
root?: string; | ||
defaultDocument?: string; | ||
}; | ||
export declare const getKVFilePath: (options: FilePathOptions) => string; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getKVFilePath = exports.getContentFromKVAsset = void 0; | ||
exports.getContentFromKVAsset = void 0; | ||
const getContentFromKVAsset = async (path, options) => { | ||
@@ -40,23 +40,1 @@ let ASSET_MANIFEST = {}; | ||
exports.getContentFromKVAsset = getContentFromKVAsset; | ||
const getKVFilePath = (options) => { | ||
let filename = options.filename; | ||
let root = options.root || ''; | ||
const defaultDocument = options.defaultDocument || 'index.html'; | ||
if (filename.endsWith('/')) { | ||
// /top/ => /top/index.html | ||
filename = filename.concat(defaultDocument); | ||
} | ||
else if (!filename.match(/\.[a-zA-Z0-9]+$/)) { | ||
// /top => /top/index.html | ||
filename = filename.concat('/' + defaultDocument); | ||
} | ||
// /foo.html => foo.html | ||
filename = filename.replace(/^\.?\//, ''); | ||
// assets/ => assets | ||
root = root.replace(/\/$/, ''); | ||
// ./assets/foo.html => assets/foo.html | ||
let path = root ? root + '/' + filename : filename; | ||
path = path.replace(/^\.?\//, ''); | ||
return path; | ||
}; | ||
exports.getKVFilePath = getKVFilePath; |
{ | ||
"name": "hono", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"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", | ||
"denoify": "rimraf deno_dist && denoify", | ||
"denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.ts'", | ||
"build": "rimraf dist && tsc --project tsconfig.build.esm.json && tsc --project tsconfig.build.json", | ||
@@ -17,0 +17,0 @@ "watch": "tsc --project tsconfig.build.json -w", |
@@ -16,4 +16,5 @@ <div align="center"> | ||
[![GitHub last commit](https://img.shields.io/github/last-commit/honojs/hono)](https://github.com/honojs/hono/commits/master) | ||
[![Deno badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fhono%2Fmod.ts)](https://doc.deno.land/https/deno.land/x/hono/mod.ts) | ||
Hono - _**[炎] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers or Service Worker based serverless such as Fastly Compute@Edge. | ||
Hono - _**[炎] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, and others. | ||
@@ -35,4 +36,3 @@ ```ts | ||
- **TypeScript** - first-class TypeScript support. | ||
- **Optimized** - for Cloudflare Workers. | ||
- **Deno** - support for Deno (Experimental). | ||
- **Multi-platform** - works on Cloudflare Workers, Fastly Compute@Edge, or Deno. | ||
@@ -768,3 +768,3 @@ ## Benchmarks | ||
import { serve } from 'https://deno.land/std@0.146.0/http/server.ts' | ||
import { Hono, logger, poweredBy, basicAuth, jsx } from 'https://deno.land/x/hono/mod.ts' | ||
import { Hono, logger, poweredBy, serveStatic, jsx } from 'https://deno.land/x/hono/mod.ts' | ||
@@ -774,14 +774,7 @@ const app = new Hono() | ||
app.use('*', logger(), poweredBy()) | ||
app.get( | ||
'/auth/*', | ||
basicAuth({ | ||
username: 'deno', | ||
password: 'isacool', | ||
}) | ||
) | ||
app.get('/favicon.ico', serveStatic({ path: './public/favicon.ico' })) | ||
app.get('/', (c) => { | ||
return c.html(<h1>Hello Deno!</h1>) | ||
}) | ||
app.get('/auth/abc', (c) => c.text('You are authorized')) | ||
@@ -788,0 +781,0 @@ serve(app.fire()) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135384
95
3010
813