srvx 0.7.5 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import * as cloudflare_workers0 from "cloudflare:workers";
1
2
  import * as NodeHttp$1 from "node:http";
2
3
  import * as NodeHttps from "node:https";
3
4
  import * as NodeHttp2 from "node:http2";
@@ -6,7 +7,10 @@ import * as Bun from "bun";
6
7
  import * as CF from "@cloudflare/workers-types";
7
8
 
8
9
  //#region src/types.d.ts
10
+ // Utils
9
11
  type MaybePromise<T> = T | Promise<T>;
12
+ type IsAny<T> = Equal<T, any> extends true ? true : false;
13
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
10
14
  // ----------------------------------------------------------------------------
11
15
  // srvx API
12
16
  // ----------------------------------------------------------------------------
@@ -218,8 +222,8 @@ interface ServerRuntimeContext {
218
222
  * Underlying Cloudflare request context.
219
223
  */
220
224
  cloudflare?: {
221
- env: unknown;
222
225
  context: CF.ExecutionContext;
226
+ env: IsAny<typeof cloudflare_workers0> extends true ? Record<string, unknown> : typeof cloudflare_workers0.env;
223
227
  };
224
228
  }
225
229
  interface ServerRequest extends Request {
@@ -1,4 +1,4 @@
1
- import { BunFetchHandler, Server, ServerOptions } from "../_chunks/types-mRjDOdKf.mjs";
1
+ import { BunFetchHandler, Server, ServerOptions } from "../_chunks/types-IGvUeyh_.mjs";
2
2
  import { FastURL$2 as FastURL } from "../_chunks/_url-CE8HuNzA.mjs";
3
3
  import * as bun from "bun";
4
4
 
@@ -1,4 +1,4 @@
1
- import { Server, ServerOptions } from "../_chunks/types-mRjDOdKf.mjs";
1
+ import { Server, ServerOptions } from "../_chunks/types-IGvUeyh_.mjs";
2
2
  import * as CF from "@cloudflare/workers-types";
3
3
 
4
4
  //#region src/adapters/cloudflare.d.ts
@@ -32,6 +32,12 @@ var CloudflareServer = class {
32
32
  context
33
33
  }
34
34
  }
35
+ },
36
+ ip: {
37
+ enumerable: true,
38
+ get() {
39
+ return request.headers.get("cf-connecting-ip");
40
+ }
35
41
  }
36
42
  });
37
43
  return fetchHandler(request);
@@ -1,4 +1,4 @@
1
- import { DenoFetchHandler, Server, ServerOptions } from "../_chunks/types-mRjDOdKf.mjs";
1
+ import { DenoFetchHandler, Server, ServerOptions } from "../_chunks/types-IGvUeyh_.mjs";
2
2
  import { FastURL$2 as FastURL } from "../_chunks/_url-CE8HuNzA.mjs";
3
3
 
4
4
  //#region src/adapters/deno.d.ts
@@ -1,4 +1,4 @@
1
- import { Server, ServerOptions } from "../_chunks/types-mRjDOdKf.mjs";
1
+ import { Server, ServerOptions } from "../_chunks/types-IGvUeyh_.mjs";
2
2
 
3
3
  //#region src/adapters/generic.d.ts
4
4
  declare const FastURL: typeof globalThis.URL;
@@ -1,4 +1,4 @@
1
- import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest } from "../_chunks/types-mRjDOdKf.mjs";
1
+ import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest } from "../_chunks/types-IGvUeyh_.mjs";
2
2
  import { FastURL$2 as FastURL } from "../_chunks/_url-CE8HuNzA.mjs";
3
3
  import NodeHttp from "node:http";
4
4
  import { Readable } from "node:stream";
@@ -385,6 +385,17 @@ function parseHost(host) {
385
385
  //#endregion
386
386
  //#region src/adapters/_node/request.ts
387
387
  const NodeRequest = /* @__PURE__ */ (() => {
388
+ const unsupportedGetters = [
389
+ "cache",
390
+ "credentials",
391
+ "destination",
392
+ "integrity",
393
+ "keepalive",
394
+ "mode",
395
+ "redirect",
396
+ "referrer",
397
+ "referrerPolicy"
398
+ ];
388
399
  const _Request = class Request {
389
400
  #url;
390
401
  #headers;
@@ -519,6 +530,10 @@ const NodeRequest = /* @__PURE__ */ (() => {
519
530
  };
520
531
  }
521
532
  };
533
+ for (const key of unsupportedGetters) Object.defineProperty(_Request.prototype, key, {
534
+ enumerable: true,
535
+ configurable: false
536
+ });
522
537
  Object.setPrototypeOf(_Request.prototype, globalThis.Request.prototype);
523
538
  return _Request;
524
539
  })();
@@ -1,4 +1,4 @@
1
- import { Server, ServerOptions, ServerRequest } from "../_chunks/types-mRjDOdKf.mjs";
1
+ import { Server, ServerOptions, ServerRequest } from "../_chunks/types-IGvUeyh_.mjs";
2
2
 
3
3
  //#region src/adapters/service-worker.d.ts
4
4
  declare const FastURL: typeof globalThis.URL;
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve } from "./_chunks/types-mRjDOdKf.mjs";
1
+ import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve } from "./_chunks/types-IGvUeyh_.mjs";
2
2
  export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srvx",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "description": "Universal Server API based on web platform standards. Works seamlessly with Deno, Bun and Node.js.",
5
5
  "homepage": "https://srvx.h3.dev",
6
6
  "repository": "h3js/srvx",
@@ -8,7 +8,6 @@
8
8
  "sideEffects": false,
9
9
  "type": "module",
10
10
  "exports": {
11
- "./types": "./dist/types.d.mts",
12
11
  "./deno": "./dist/adapters/deno.mjs",
13
12
  "./bun": "./dist/adapters/bun.mjs",
14
13
  "./node": "./dist/adapters/node.mjs",
@@ -57,33 +56,33 @@
57
56
  "cookie-es": "^2.0.0"
58
57
  },
59
58
  "devDependencies": {
60
- "@cloudflare/workers-types": "^4.20250525.0",
61
- "@hono/node-server": "^1.14.3",
59
+ "@cloudflare/workers-types": "^4.20250627.0",
60
+ "@hono/node-server": "^1.14.4",
62
61
  "@mitata/counters": "^0.0.8",
63
- "@mjackson/node-fetch-server": "^0.6.1",
64
- "@types/bun": "^1.2.14",
62
+ "@mjackson/node-fetch-server": "^0.7.0",
63
+ "@types/bun": "^1.2.17",
65
64
  "@types/deno": "^2.3.0",
66
- "@types/node": "^22.15.21",
65
+ "@types/node": "^24.0.4",
67
66
  "@types/node-forge": "^1.3.11",
68
- "@types/serviceworker": "^0.0.135",
69
- "@vitest/coverage-v8": "^3.1.4",
67
+ "@types/serviceworker": "^0.0.139",
68
+ "@vitest/coverage-v8": "^3.2.4",
70
69
  "@whatwg-node/server": "^0.10.10",
71
70
  "automd": "^0.4.0",
72
71
  "changelogen": "^0.6.1",
73
- "eslint": "^9.27.0",
74
- "eslint-config-unjs": "^0.4.2",
72
+ "eslint": "^9.29.0",
73
+ "eslint-config-unjs": "^0.5.0",
75
74
  "execa": "^9.6.0",
76
75
  "get-port-please": "^3.1.2",
77
76
  "mitata": "^1.0.34",
78
77
  "node-forge": "^1.3.1",
79
- "obuild": "^0.2.0",
80
- "prettier": "^3.5.3",
78
+ "obuild": "^0.2.1",
79
+ "prettier": "^3.6.2",
81
80
  "tslib": "^2.8.1",
82
81
  "typescript": "^5.8.3",
83
- "undici": "^7.10.0",
84
- "vitest": "^3.1.4"
82
+ "undici": "^7.11.0",
83
+ "vitest": "^3.2.4"
85
84
  },
86
- "packageManager": "pnpm@10.11.0",
85
+ "packageManager": "pnpm@10.12.4",
87
86
  "engines": {
88
87
  "node": ">=20.16.0"
89
88
  }