🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

hono

Package Overview
Dependencies
Maintainers
1
Versions
434
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
4.12.22
to
4.12.23
+3
-0
dist/cjs/index.js

@@ -20,2 +20,3 @@ var __defProp = Object.defineProperty;

__export(index_exports, {
Context: () => import_context.Context,
Hono: () => import_hono.Hono

@@ -25,5 +26,7 @@ });

var import_hono = require("./hono");
var import_context = require("./context");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Context,
Hono
});
+10
-4

@@ -20,2 +20,3 @@ var __defProp = Object.defineProperty;

__export(compress_exports, {
COMPRESSIBLE_CONTENT_TYPE_REGEX: () => import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX,
compress: () => compress

@@ -49,2 +50,10 @@ });

const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
const contentTypeFilter = options?.contentTypeFilter ?? import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX;
const shouldCompress = typeof contentTypeFilter === "function" ? (res) => {
const type = res.headers.get("Content-Type");
return type && contentTypeFilter(type);
} : (res) => {
const type = res.headers.get("Content-Type");
return type && contentTypeFilter.test(type);
};
return async function compress2(ctx, next) {

@@ -76,6 +85,2 @@ await next();

};
const shouldCompress = (res) => {
const type = res.headers.get("Content-Type");
return type && import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type);
};
const shouldTransform = (res) => {

@@ -87,3 +92,4 @@ const cacheControl = res.headers.get("Cache-Control");

0 && (module.exports = {
COMPRESSIBLE_CONTENT_TYPE_REGEX,
compress
});

@@ -45,3 +45,3 @@ var __defProp = Object.defineProperty;

filename = filename.replace(/^\.?[\/\\]/, "");
filename = filename.replace(/\\/, "/");
filename = filename.replace(/\\/g, "/");
root = root.replace(/\/$/, "");

@@ -48,0 +48,0 @@ let path = root ? root + "/" + filename : filename;

@@ -297,3 +297,3 @@ var __defProp = Object.defineProperty;

}
if (maxZeroStart !== -1) {
if (maxZeroStart !== -1 && maxZeroEnd - maxZeroStart > 1) {
sections.splice(maxZeroStart, maxZeroEnd - maxZeroStart, ":");

@@ -300,0 +300,0 @@ }

// src/index.ts
import { Hono } from "./hono.js";
import { Context } from "./context.js";
export {
Context,
Hono
};

@@ -27,2 +27,10 @@ // src/middleware/compress/index.ts

const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
const contentTypeFilter = options?.contentTypeFilter ?? COMPRESSIBLE_CONTENT_TYPE_REGEX;
const shouldCompress = typeof contentTypeFilter === "function" ? (res) => {
const type = res.headers.get("Content-Type");
return type && contentTypeFilter(type);
} : (res) => {
const type = res.headers.get("Content-Type");
return type && contentTypeFilter.test(type);
};
return async function compress2(ctx, next) {

@@ -54,6 +62,2 @@ await next();

};
var shouldCompress = (res) => {
const type = res.headers.get("Content-Type");
return type && COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type);
};
var shouldTransform = (res) => {

@@ -64,3 +68,4 @@ const cacheControl = res.headers.get("Cache-Control");

export {
COMPRESSIBLE_CONTENT_TYPE_REGEX,
compress
};

@@ -24,3 +24,4 @@ /**

*/
export type { Context, ContextVariableMap, ContextRenderer, ExecutionContext } from './context';
export { Context } from './context';
export type { ContextVariableMap, ContextRenderer, ExecutionContext } from './context';
/**

@@ -27,0 +28,0 @@ * Type for HonoRequest.

@@ -6,7 +6,11 @@ /**

import type { MiddlewareHandler } from '../../types';
import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from '../../utils/compress';
export { COMPRESSIBLE_CONTENT_TYPE_REGEX };
declare const ENCODING_TYPES: readonly ["gzip", "deflate"];
type Encoding = (typeof ENCODING_TYPES)[number];
type ContentTypeFilter = RegExp | ((contentType: string) => boolean);
interface CompressionOptions {
encoding?: Encoding;
threshold?: number;
contentTypeFilter?: ContentTypeFilter;
}

@@ -21,2 +25,3 @@ /**

* @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes.
* @param {RegExp | Function} [options.contentTypeFilter=COMPRESSIBLE_CONTENT_TYPE_REGEX] - A RegExp or function to determine if the response Content-Type should be compressed.
* @returns {MiddlewareHandler} The middleware handler function.

@@ -29,5 +34,10 @@ *

* app.use(compress())
*
* // Compress only JSON responses
* app.use(compress({ contentTypeFilter: /^application\/json/ }))
*
* // Compress based on custom Content-Type logic
* app.use(compress({ contentTypeFilter: (type) => COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type) || type === "application/x-myformat" }))
* ```
*/
export declare const compress: (options?: CompressionOptions) => MiddlewareHandler;
export {};

@@ -23,3 +23,3 @@ // src/utils/filepath.ts

filename = filename.replace(/^\.?[\/\\]/, "");
filename = filename.replace(/\\/, "/");
filename = filename.replace(/\\/g, "/");
root = root.replace(/\/$/, "");

@@ -26,0 +26,0 @@ let path = root ? root + "/" + filename : filename;

@@ -268,3 +268,3 @@ // src/utils/ipaddr.ts

}
if (maxZeroStart !== -1) {
if (maxZeroStart !== -1 && maxZeroEnd - maxZeroStart > 1) {
sections.splice(maxZeroStart, maxZeroEnd - maxZeroStart, ":");

@@ -271,0 +271,0 @@ }

{
"name": "hono",
"version": "4.12.22",
"version": "4.12.23",
"description": "Web framework built on Web Standards",

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

Sorry, the diff of this file is not supported yet