Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hono

Package Overview
Dependencies
Maintainers
1
Versions
338
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hono - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

dist/middleware/serve-static/serve-static.d.ts

19

dist/context.js

@@ -27,5 +27,18 @@ "use strict";

init.statusText = init.statusText || this._statusText;
const Encoder = new TextEncoder();
const length = data ? data.bytelength || Encoder.encode(data).byteLength : 0;
init.headers = Object.assign(Object.assign(Object.assign({}, this._headers), init.headers), { 'Content-Length': String(length) });
init.headers = Object.assign(Object.assign({}, this._headers), init.headers);
// Content-Length
let length = 0;
if (data) {
if (data instanceof ArrayBuffer) {
length = data.byteLength;
}
else if (typeof data == 'string') {
const Encoder = new TextEncoder();
length = Encoder.encode(data).byteLength || 0;
}
else {
length = data.bytelength;
}
}
init.headers = Object.assign(Object.assign({}, init.headers), { 'Content-Length': length.toString() });
return new Response(data, init);

@@ -32,0 +45,0 @@ }

@@ -51,2 +51,3 @@ "use strict";

/*
We may implement these HTTP methods:
trace

@@ -53,0 +54,0 @@ copy

@@ -25,2 +25,5 @@ export declare class Middleware {

static mustache: () => (c: import("./context").Context, next: Function) => Promise<void>;
static serveStatic: (opt?: {
root: string;
}) => (c: import("./context").Context, next: Function) => Promise<void>;
}

@@ -12,2 +12,3 @@ "use strict";

const mustache_1 = require("./middleware/mustache/mustache");
const serve_static_1 = require("./middleware/serve-static/serve-static");
class Middleware {

@@ -24,1 +25,2 @@ }

Middleware.mustache = mustache_1.mustache;
Middleware.serveStatic = serve_static_1.serveStatic;

18

dist/middleware/mustache/mustache.js

@@ -19,6 +19,7 @@ "use strict";

c.render = async (filename, view = {}, options) => {
const content = await (0, cloudflare_1.getContentFromKVAsset)(`${filename}${EXTENSION}`);
if (!content) {
const buffer = await (0, cloudflare_1.getContentFromKVAsset)(`${filename}${EXTENSION}`);
if (!buffer) {
throw new Error(`Template "${filename}${EXTENSION}" is not found or blank.`);
}
const content = bufferToString(buffer);
const partialArgs = {};

@@ -28,7 +29,7 @@ if (options) {

for (const key of Object.keys(partials)) {
const partialContent = await (0, cloudflare_1.getContentFromKVAsset)(`${partials[key]}${EXTENSION}`);
if (!partialContent) {
const partialBuffer = await (0, cloudflare_1.getContentFromKVAsset)(`${partials[key]}${EXTENSION}`);
if (!partialBuffer) {
throw new Error(`Partial Template "${partials[key]}${EXTENSION}" is not found or blank.`);
}
partialArgs[key] = partialContent;
partialArgs[key] = bufferToString(partialBuffer);
}

@@ -43,1 +44,8 @@ }

exports.mustache = mustache;
const bufferToString = (buffer) => {
if (buffer instanceof ArrayBuffer) {
const enc = new TextDecoder('utf-8');
return enc.decode(buffer);
}
return buffer;
};

@@ -1,1 +0,1 @@

export declare const getContentFromKVAsset: (path: string) => Promise<string>;
export declare const getContentFromKVAsset: (path: string) => Promise<ArrayBuffer>;

@@ -17,4 +17,3 @@ "use strict";

}
let content;
content = await ASSET_NAMESPACE.get(key, { type: 'text' });
let content = await ASSET_NAMESPACE.get(key, { type: 'arrayBuffer' });
if (content) {

@@ -21,0 +20,0 @@ content = content;

{
"name": "hono",
"version": "0.2.3",
"version": "0.2.4",
"description": "[炎] Ultrafast web framework for Cloudflare Workers.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -361,2 +361,7 @@ # Hono

}
/*
or just do this:
export default app
*/
```

@@ -363,0 +368,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc