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

@hono/node-server

Package Overview
Dependencies
Maintainers
1
Versions
53
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.3.3 to 1.3.4

2

dist/index.d.ts

@@ -6,3 +6,3 @@ export { createAdaptorServer, serve } from './server.js';

import 'node:http';
import 'node:http2';
import 'node:https';
import 'node:http2';

@@ -42,4 +42,67 @@ "use strict";

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};

@@ -169,2 +232,3 @@ // src/utils.ts

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
Object.defineProperty(global, "Response", {

@@ -187,68 +251,2 @@ value: Response2

// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};
// src/listener.ts

@@ -266,2 +264,5 @@ var regBuffer = /^no$/i;

console.error(e);
if (!outgoing.headersSent)
outgoing.writeHead(500, { "Content-Type": "text/plain" });
outgoing.end(`Error: ${err.message}`);
outgoing.destroy(err);

@@ -287,2 +288,9 @@ }

}
if (!(res instanceof Response)) {
return handleResponseError(
// @ts-expect-error the object must have `toString()`
new Error(`The response is not an instance of Response, but ${res.toString()}`),
outgoing
);
}
if (cacheKey in res) {

@@ -289,0 +297,0 @@ try {

@@ -37,4 +37,67 @@ "use strict";

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};

@@ -164,2 +227,3 @@ // src/utils.ts

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
Object.defineProperty(global, "Response", {

@@ -182,68 +246,2 @@ value: Response2

// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};
// src/listener.ts

@@ -261,2 +259,5 @@ var regBuffer = /^no$/i;

console.error(e);
if (!outgoing.headersSent)
outgoing.writeHead(500, { "Content-Type": "text/plain" });
outgoing.end(`Error: ${err.message}`);
outgoing.destroy(err);

@@ -282,2 +283,9 @@ }

}
if (!(res instanceof Response)) {
return handleResponseError(
// @ts-expect-error the object must have `toString()`
new Error(`The response is not an instance of Response, but ${res.toString()}`),
outgoing
);
}
if (cacheKey in res) {

@@ -284,0 +292,0 @@ try {

import { AddressInfo } from 'node:net';
import { Options, ServerType } from './types.js';
import 'node:http';
import 'node:http2';
import 'node:https';
import 'node:http2';

@@ -7,0 +7,0 @@ declare const createAdaptorServer: (options: Options) => ServerType;

@@ -39,4 +39,67 @@ "use strict";

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};

@@ -166,2 +229,3 @@ // src/utils.ts

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
Object.defineProperty(global, "Response", {

@@ -184,68 +248,2 @@ value: Response2

// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};
// src/listener.ts

@@ -263,2 +261,5 @@ var regBuffer = /^no$/i;

console.error(e);
if (!outgoing.headersSent)
outgoing.writeHead(500, { "Content-Type": "text/plain" });
outgoing.end(`Error: ${err.message}`);
outgoing.destroy(err);

@@ -284,2 +285,9 @@ }

}
if (!(res instanceof Response)) {
return handleResponseError(
// @ts-expect-error the object must have `toString()`
new Error(`The response is not an instance of Response, but ${res.toString()}`),
outgoing
);
}
if (cacheKey in res) {

@@ -286,0 +294,0 @@ try {

import { Server, ServerOptions as ServerOptions$1, createServer } from 'node:http';
import { 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';
import { Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';

@@ -5,0 +5,0 @@ type FetchCallback = (request: Request) => Promise<unknown> | unknown;

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

import { OutgoingHttpHeaders } from 'node:http';
import { Writable } from 'node:stream';
import { OutgoingHttpHeaders } from 'node:http';

@@ -4,0 +4,0 @@ declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;

@@ -37,4 +37,67 @@ "use strict";

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};

@@ -164,2 +227,3 @@ // src/utils.ts

// src/globals.ts
var import_node_crypto = __toESM(require("crypto"));
Object.defineProperty(global, "Response", {

@@ -182,68 +246,2 @@ value: Response2

// src/request.ts
var import_node_stream = require("stream");
var newRequestFromIncoming = (method, url, incoming) => {
const headerRecord = [];
const len = incoming.rawHeaders.length;
for (let i = 0; i < len; i += 2) {
headerRecord.push([incoming.rawHeaders[i], incoming.rawHeaders[i + 1]]);
}
const init = {
method,
headers: headerRecord
};
if (!(method === "GET" || method === "HEAD")) {
init.body = import_node_stream.Readable.toWeb(incoming);
init.duplex = "half";
}
return new Request(url, init);
};
var getRequestCache = Symbol("getRequestCache");
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var requestPrototype = {
get method() {
return this[incomingKey].method || "GET";
},
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`;
},
[getRequestCache]() {
return this[requestCache] ||= newRequestFromIncoming(this.method, this.url, this[incomingKey]);
}
};
[
"body",
"bodyUsed",
"cache",
"credentials",
"destination",
"headers",
"integrity",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal"
].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
get() {
return this[getRequestCache]()[k];
}
});
});
["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
Object.defineProperty(requestPrototype, k, {
value: function() {
return this[getRequestCache]()[k]();
}
});
});
Object.setPrototypeOf(requestPrototype, global.Request.prototype);
var newRequest = (incoming) => {
const req = Object.create(requestPrototype);
req[incomingKey] = incoming;
return req;
};
// src/listener.ts

@@ -261,2 +259,5 @@ var regBuffer = /^no$/i;

console.error(e);
if (!outgoing.headersSent)
outgoing.writeHead(500, { "Content-Type": "text/plain" });
outgoing.end(`Error: ${err.message}`);
outgoing.destroy(err);

@@ -282,2 +283,9 @@ }

}
if (!(res instanceof Response)) {
return handleResponseError(
// @ts-expect-error the object must have `toString()`
new Error(`The response is not an instance of Response, but ${res.toString()}`),
outgoing
);
}
if (cacheKey in res) {

@@ -284,0 +292,0 @@ try {

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

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

"prerelease": "yarn build && yarn test",
"release": "np"
"release": "np",
"lint": "eslint --ext js,ts src test",
"lint:fix": "eslint --ext js,ts src test --fix"
},

@@ -64,6 +66,8 @@ "license": "MIT",

"devDependencies": {
"@hono/eslint-config": "^0.0.2",
"@types/jest": "^29.5.3",
"@types/node": "^20.10.0",
"@types/supertest": "^2.0.12",
"hono": "^3.9.2",
"eslint": "^8.55.0",
"hono": "^3.11.7",
"jest": "^29.6.1",

@@ -70,0 +74,0 @@ "np": "^7.7.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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