@hono/node-server
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -48,11 +48,18 @@ "use strict"; | ||
var responseCache = Symbol("responseCache"); | ||
var newGlobalResponseKey = Symbol("newGlobalResponse"); | ||
var cacheKey = Symbol("cache"); | ||
var globalResponse = global.Response; | ||
var Response = class { | ||
var GlobalResponse = global.Response; | ||
var Response = class _Response { | ||
#body; | ||
#init; | ||
[newGlobalResponseKey]() { | ||
return new GlobalResponse( | ||
this.#body, | ||
this.#init instanceof _Response ? this.#init[newGlobalResponseKey]() : this.#init | ||
); | ||
} | ||
// @ts-ignore | ||
get cache() { | ||
delete this[cacheKey]; | ||
return this[responseCache] ||= new globalResponse(this.#body, this.#init); | ||
return this[responseCache] ||= this[newGlobalResponseKey](); | ||
} | ||
@@ -96,4 +103,4 @@ constructor(body, init) { | ||
}); | ||
Object.setPrototypeOf(Response, globalResponse); | ||
Object.setPrototypeOf(Response.prototype, globalResponse.prototype); | ||
Object.setPrototypeOf(Response, GlobalResponse); | ||
Object.setPrototypeOf(Response.prototype, GlobalResponse.prototype); | ||
Object.defineProperty(global, "Response", { | ||
@@ -100,0 +107,0 @@ value: Response |
@@ -103,11 +103,18 @@ "use strict"; | ||
var responseCache = Symbol("responseCache"); | ||
var newGlobalResponseKey = Symbol("newGlobalResponse"); | ||
var cacheKey = Symbol("cache"); | ||
var globalResponse = global.Response; | ||
var Response2 = class { | ||
var GlobalResponse = global.Response; | ||
var Response2 = class _Response { | ||
#body; | ||
#init; | ||
[newGlobalResponseKey]() { | ||
return new GlobalResponse( | ||
this.#body, | ||
this.#init instanceof _Response ? this.#init[newGlobalResponseKey]() : this.#init | ||
); | ||
} | ||
// @ts-ignore | ||
get cache() { | ||
delete this[cacheKey]; | ||
return this[responseCache] ||= new globalResponse(this.#body, this.#init); | ||
return this[responseCache] ||= this[newGlobalResponseKey](); | ||
} | ||
@@ -151,4 +158,4 @@ constructor(body, init) { | ||
}); | ||
Object.setPrototypeOf(Response2, globalResponse); | ||
Object.setPrototypeOf(Response2.prototype, globalResponse.prototype); | ||
Object.setPrototypeOf(Response2, GlobalResponse); | ||
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype); | ||
Object.defineProperty(global, "Response", { | ||
@@ -155,0 +162,0 @@ value: Response2 |
@@ -98,11 +98,18 @@ "use strict"; | ||
var responseCache = Symbol("responseCache"); | ||
var newGlobalResponseKey = Symbol("newGlobalResponse"); | ||
var cacheKey = Symbol("cache"); | ||
var globalResponse = global.Response; | ||
var Response2 = class { | ||
var GlobalResponse = global.Response; | ||
var Response2 = class _Response { | ||
#body; | ||
#init; | ||
[newGlobalResponseKey]() { | ||
return new GlobalResponse( | ||
this.#body, | ||
this.#init instanceof _Response ? this.#init[newGlobalResponseKey]() : this.#init | ||
); | ||
} | ||
// @ts-ignore | ||
get cache() { | ||
delete this[cacheKey]; | ||
return this[responseCache] ||= new globalResponse(this.#body, this.#init); | ||
return this[responseCache] ||= this[newGlobalResponseKey](); | ||
} | ||
@@ -146,4 +153,4 @@ constructor(body, init) { | ||
}); | ||
Object.setPrototypeOf(Response2, globalResponse); | ||
Object.setPrototypeOf(Response2.prototype, globalResponse.prototype); | ||
Object.setPrototypeOf(Response2, GlobalResponse); | ||
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype); | ||
Object.defineProperty(global, "Response", { | ||
@@ -150,0 +157,0 @@ value: Response2 |
@@ -0,3 +1,4 @@ | ||
declare const newGlobalResponseKey: unique symbol; | ||
declare const cacheKey: unique symbol; | ||
declare const globalResponse: { | ||
declare const GlobalResponse: { | ||
new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): globalThis.Response; | ||
@@ -11,2 +12,3 @@ prototype: globalThis.Response; | ||
#private; | ||
[newGlobalResponseKey](): typeof GlobalResponse; | ||
private get cache(); | ||
@@ -16,2 +18,2 @@ constructor(body?: BodyInit | null, init?: ResponseInit); | ||
export { Response, cacheKey, globalResponse }; | ||
export { GlobalResponse, Response, cacheKey }; |
@@ -23,5 +23,5 @@ "use strict"; | ||
__export(response_exports, { | ||
GlobalResponse: () => GlobalResponse, | ||
Response: () => Response, | ||
cacheKey: () => cacheKey, | ||
globalResponse: () => globalResponse | ||
cacheKey: () => cacheKey | ||
}); | ||
@@ -50,11 +50,18 @@ module.exports = __toCommonJS(response_exports); | ||
var responseCache = Symbol("responseCache"); | ||
var newGlobalResponseKey = Symbol("newGlobalResponse"); | ||
var cacheKey = Symbol("cache"); | ||
var globalResponse = global.Response; | ||
var Response = class { | ||
var GlobalResponse = global.Response; | ||
var Response = class _Response { | ||
#body; | ||
#init; | ||
[newGlobalResponseKey]() { | ||
return new GlobalResponse( | ||
this.#body, | ||
this.#init instanceof _Response ? this.#init[newGlobalResponseKey]() : this.#init | ||
); | ||
} | ||
// @ts-ignore | ||
get cache() { | ||
delete this[cacheKey]; | ||
return this[responseCache] ||= new globalResponse(this.#body, this.#init); | ||
return this[responseCache] ||= this[newGlobalResponseKey](); | ||
} | ||
@@ -98,4 +105,4 @@ constructor(body, init) { | ||
}); | ||
Object.setPrototypeOf(Response, globalResponse); | ||
Object.setPrototypeOf(Response.prototype, globalResponse.prototype); | ||
Object.setPrototypeOf(Response, GlobalResponse); | ||
Object.setPrototypeOf(Response.prototype, GlobalResponse.prototype); | ||
Object.defineProperty(global, "Response", { | ||
@@ -106,5 +113,5 @@ value: Response | ||
0 && (module.exports = { | ||
GlobalResponse, | ||
Response, | ||
cacheKey, | ||
globalResponse | ||
cacheKey | ||
}); |
@@ -100,11 +100,18 @@ "use strict"; | ||
var responseCache = Symbol("responseCache"); | ||
var newGlobalResponseKey = Symbol("newGlobalResponse"); | ||
var cacheKey = Symbol("cache"); | ||
var globalResponse = global.Response; | ||
var Response2 = class { | ||
var GlobalResponse = global.Response; | ||
var Response2 = class _Response { | ||
#body; | ||
#init; | ||
[newGlobalResponseKey]() { | ||
return new GlobalResponse( | ||
this.#body, | ||
this.#init instanceof _Response ? this.#init[newGlobalResponseKey]() : this.#init | ||
); | ||
} | ||
// @ts-ignore | ||
get cache() { | ||
delete this[cacheKey]; | ||
return this[responseCache] ||= new globalResponse(this.#body, this.#init); | ||
return this[responseCache] ||= this[newGlobalResponseKey](); | ||
} | ||
@@ -148,4 +155,4 @@ constructor(body, init) { | ||
}); | ||
Object.setPrototypeOf(Response2, globalResponse); | ||
Object.setPrototypeOf(Response2.prototype, globalResponse.prototype); | ||
Object.setPrototypeOf(Response2, GlobalResponse); | ||
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype); | ||
Object.defineProperty(global, "Response", { | ||
@@ -152,0 +159,0 @@ value: Response2 |
@@ -98,11 +98,18 @@ "use strict"; | ||
var responseCache = Symbol("responseCache"); | ||
var newGlobalResponseKey = Symbol("newGlobalResponse"); | ||
var cacheKey = Symbol("cache"); | ||
var globalResponse = global.Response; | ||
var Response2 = class { | ||
var GlobalResponse = global.Response; | ||
var Response2 = class _Response { | ||
#body; | ||
#init; | ||
[newGlobalResponseKey]() { | ||
return new GlobalResponse( | ||
this.#body, | ||
this.#init instanceof _Response ? this.#init[newGlobalResponseKey]() : this.#init | ||
); | ||
} | ||
// @ts-ignore | ||
get cache() { | ||
delete this[cacheKey]; | ||
return this[responseCache] ||= new globalResponse(this.#body, this.#init); | ||
return this[responseCache] ||= this[newGlobalResponseKey](); | ||
} | ||
@@ -146,4 +153,4 @@ constructor(body, init) { | ||
}); | ||
Object.setPrototypeOf(Response2, globalResponse); | ||
Object.setPrototypeOf(Response2.prototype, globalResponse.prototype); | ||
Object.setPrototypeOf(Response2, GlobalResponse); | ||
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype); | ||
Object.defineProperty(global, "Response", { | ||
@@ -150,0 +157,0 @@ value: Response2 |
{ | ||
"name": "@hono/node-server", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Node.js Adapter for Hono", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# Node.js Adapter for Hono | ||
This adapter allows you to run your Hono application on Node.js. Initially, Hono wasn't designed for Node.js, but with this adapter, it can now be used with Node.js. It utilizes web standard APIs implemented in Node.js version 18 or higher. | ||
This adapter `@hono/node-server` allows you to run your Hono application on Node.js. | ||
Initially, Hono wasn't designed for Node.js, but with this adapter, you can now use Hono on Node.js. | ||
It utilizes web standard APIs implemented in Node.js version 18 or higher. | ||
While Hono is ultra-fast, it may not be as fast on Node.js due to the overhead involved in adapting Hono's API to Node.js. | ||
## Benchmarks | ||
However, it's worth noting that it is still faster than Express. | ||
Hono is 3.5 times faster than Express. | ||
## Requirement | ||
Express: | ||
```txt | ||
$ bombardier -d 10s --fasthttp http://localhost:3000/ | ||
Statistics Avg Stdev Max | ||
Reqs/sec 16438.94 1603.39 19155.47 | ||
Latency 7.60ms 7.51ms 559.89ms | ||
HTTP codes: | ||
1xx - 0, 2xx - 164494, 3xx - 0, 4xx - 0, 5xx - 0 | ||
others - 0 | ||
Throughput: 4.55MB/s | ||
``` | ||
Hono + `@hono/node-server`: | ||
```txt | ||
$ bombardier -d 10s --fasthttp http://localhost:3000/ | ||
Statistics Avg Stdev Max | ||
Reqs/sec 58296.56 5512.74 74403.56 | ||
Latency 2.14ms 1.46ms 190.92ms | ||
HTTP codes: | ||
1xx - 0, 2xx - 583059, 3xx - 0, 4xx - 0, 5xx - 0 | ||
others - 0 | ||
Throughput: 12.56MB/s | ||
``` | ||
## Requirements | ||
It works on Node.js versions greater than 18.x. The specific required Node.js versions are as follows: | ||
@@ -19,3 +49,3 @@ | ||
## Install | ||
## Installation | ||
@@ -22,0 +52,0 @@ You can install from npm registry with `npm` command: |
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
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
118578
3697
177