You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@hono/node-server

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hono/node-server - npm Package Compare versions

Comparing version
1.17.0
to
1.17.1
+1
-1
dist/globals.d.mts
export { }
export { }
export { }
export { }

@@ -298,16 +298,13 @@ "use strict";

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -318,3 +315,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -328,6 +325,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -334,0 +331,0 @@ }

@@ -259,16 +259,13 @@ // src/server.ts

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -279,3 +276,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -289,6 +286,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -295,0 +292,0 @@ }

@@ -290,16 +290,13 @@ "use strict";

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -310,3 +307,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -320,6 +317,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -326,0 +323,0 @@ }

@@ -256,16 +256,13 @@ // src/listener.ts

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -276,3 +273,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -286,6 +283,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -292,0 +289,0 @@ }

@@ -25,2 +25,2 @@ import { IncomingMessage } from 'node:http';

export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };

@@ -25,2 +25,2 @@ import { IncomingMessage } from 'node:http';

export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };

@@ -26,2 +26,2 @@ import { OutgoingHttpHeaders } from 'node:http';

export { GlobalResponse, type InternalCache, Response, cacheKey };
export { GlobalResponse, InternalCache, Response, cacheKey };

@@ -26,2 +26,2 @@ import { OutgoingHttpHeaders } from 'node:http';

export { GlobalResponse, type InternalCache, Response, cacheKey };
export { GlobalResponse, InternalCache, Response, cacheKey };

@@ -17,2 +17,2 @@ import { Env, Context, MiddlewareHandler } from 'hono';

export { type ServeStaticOptions, serveStatic };
export { ServeStaticOptions, serveStatic };

@@ -17,2 +17,2 @@ import { Env, Context, MiddlewareHandler } from 'hono';

export { type ServeStaticOptions, serveStatic };
export { ServeStaticOptions, serveStatic };

@@ -61,3 +61,3 @@ "use strict";

var serveStatic = (options = { root: "" }) => {
const root = (0, import_node_path.resolve)(options.root || ".");
const root = options.root || "";
const optionPath = options.path;

@@ -69,26 +69,23 @@ return async (c, next) => {

let filename;
try {
const rawPath = optionPath ?? c.req.path;
if (!optionPath) {
const decodedPath = decodeURIComponent(rawPath);
if (decodedPath.includes("..")) {
await options.onNotFound?.(rawPath, c);
return next();
if (optionPath) {
filename = optionPath;
} else {
try {
filename = decodeURIComponent(c.req.path);
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
throw new Error();
}
} catch {
await options.onNotFound?.(c.req.path, c);
return next();
}
filename = optionPath ?? decodeURIComponent(c.req.path);
} catch {
await options.onNotFound?.(c.req.path, c);
return next();
}
const requestPath = options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename;
let path = optionPath ? options.root ? (0, import_node_path.resolve)((0, import_node_path.join)(root, optionPath)) : optionPath : (0, import_node_path.resolve)((0, import_node_path.join)(root, requestPath));
let path = (0, import_node_path.join)(
root,
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
);
let stats = getStats(path);
if (stats && stats.isDirectory()) {
const indexFile = options.index ?? "index.html";
path = (0, import_node_path.resolve)((0, import_node_path.join)(path, indexFile));
if (!optionPath && !path.startsWith(root)) {
await options.onNotFound?.(path, c);
return next();
}
path = (0, import_node_path.join)(path, indexFile);
stats = getStats(path);

@@ -95,0 +92,0 @@ }

// src/serve-static.ts
import { getMimeType } from "hono/utils/mime";
import { createReadStream, lstatSync } from "fs";
import { join, resolve } from "path";
import { join } from "path";
var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;

@@ -37,3 +37,3 @@ var ENCODINGS = {

var serveStatic = (options = { root: "" }) => {
const root = resolve(options.root || ".");
const root = options.root || "";
const optionPath = options.path;

@@ -45,26 +45,23 @@ return async (c, next) => {

let filename;
try {
const rawPath = optionPath ?? c.req.path;
if (!optionPath) {
const decodedPath = decodeURIComponent(rawPath);
if (decodedPath.includes("..")) {
await options.onNotFound?.(rawPath, c);
return next();
if (optionPath) {
filename = optionPath;
} else {
try {
filename = decodeURIComponent(c.req.path);
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
throw new Error();
}
} catch {
await options.onNotFound?.(c.req.path, c);
return next();
}
filename = optionPath ?? decodeURIComponent(c.req.path);
} catch {
await options.onNotFound?.(c.req.path, c);
return next();
}
const requestPath = options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename;
let path = optionPath ? options.root ? resolve(join(root, optionPath)) : optionPath : resolve(join(root, requestPath));
let path = join(
root,
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
);
let stats = getStats(path);
if (stats && stats.isDirectory()) {
const indexFile = options.index ?? "index.html";
path = resolve(join(path, indexFile));
if (!optionPath && !path.startsWith(root)) {
await options.onNotFound?.(path, c);
return next();
}
path = join(path, indexFile);
stats = getStats(path);

@@ -71,0 +68,0 @@ }

@@ -294,16 +294,13 @@ "use strict";

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -314,3 +311,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -324,6 +321,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -330,0 +327,0 @@ }

@@ -259,16 +259,13 @@ // src/server.ts

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -279,3 +276,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -289,6 +286,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -295,0 +292,0 @@ }

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

import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2';
import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';

@@ -44,2 +44,2 @@

export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };

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

import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2';
import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse, Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';

@@ -44,2 +44,2 @@

export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
import { OutgoingHttpHeaders } from 'node:http';
import { Writable } from 'node:stream';
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<void> | undefined;
declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders;
export { buildOutgoingHttpHeaders, writeFromReadableStream };
import { OutgoingHttpHeaders } from 'node:http';
import { Writable } from 'node:stream';
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<void> | undefined;
declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders;
export { buildOutgoingHttpHeaders, writeFromReadableStream };

@@ -31,16 +31,13 @@ "use strict";

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -51,3 +48,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -61,6 +58,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -67,0 +64,0 @@ }

@@ -6,16 +6,13 @@ // src/utils.ts

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -26,3 +23,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -36,6 +33,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -42,0 +39,0 @@ }

@@ -292,16 +292,13 @@ "use strict";

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -312,3 +309,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -322,6 +319,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -328,0 +325,0 @@ }

@@ -256,16 +256,13 @@ // src/listener.ts

} else if (writable.destroyed) {
stream.cancel();
return;
}
const reader = stream.getReader();
writable.on("close", cancel);
writable.on("error", cancel);
reader.read().then(flow, cancel);
const handleError = () => {
};
writable.on("error", handleError);
reader.read().then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
writable.off("error", handleError);
});
function cancel(error) {
reader.cancel(error).catch(() => {
});
function handleStreamError(error) {
if (error) {

@@ -276,3 +273,3 @@ writable.destroy(error);

function onDrain() {
reader.read().then(flow, cancel);
reader.read().then(flow, handleStreamError);
}

@@ -286,6 +283,6 @@ function flow({ done, value }) {

} else {
return reader.read().then(flow, cancel);
return reader.read().then(flow, handleStreamError);
}
} catch (e) {
cancel(e);
handleStreamError(e);
}

@@ -292,0 +289,0 @@ }

{
"name": "@hono/node-server",
"version": "1.17.0",
"version": "1.17.1",
"description": "Node.js Adapter for Hono",

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