srvx 0.11.4 → 0.11.6

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.
@@ -12,6 +12,7 @@ declare class BunServer implements Server<BunFetchHandler> {
12
12
  readonly bun: Server["bun"];
13
13
  readonly serveOptions: bun.Serve.Options<any> | undefined;
14
14
  readonly fetch: BunFetchHandler;
15
+ readonly waitUntil?: Server["waitUntil"];
15
16
  constructor(options: ServerOptions);
16
17
  serve(): Promise<this>;
17
18
  get url(): string | undefined;
@@ -11,6 +11,7 @@ var BunServer = class {
11
11
  bun = {};
12
12
  serveOptions;
13
13
  fetch;
14
+ waitUntil;
14
15
  #wait;
15
16
  constructor(options) {
16
17
  this.options = {
@@ -27,6 +28,7 @@ var BunServer = class {
27
28
  return;
28
29
  }
29
30
  this.#wait = createWaitUntil();
31
+ this.waitUntil = this.#wait.waitUntil;
30
32
  this.fetch = (request, server) => {
31
33
  Object.defineProperties(request, {
32
34
  waitUntil: { value: this.#wait?.waitUntil },
@@ -0,0 +1,8 @@
1
+ import { Server, ServerOptions } from "../types.mjs";
2
+
3
+ //#region src/adapters/bunny.d.ts
4
+ declare const FastURL: typeof globalThis.URL;
5
+ declare const FastResponse: typeof globalThis.Response;
6
+ declare function serve(options: ServerOptions): Server;
7
+ //#endregion
8
+ export { FastResponse, FastURL, serve };
@@ -0,0 +1,54 @@
1
+ import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
2
+ const FastURL = URL;
3
+ const FastResponse = Response;
4
+ function serve(options) {
5
+ return new BunnyServer(options);
6
+ }
7
+ var BunnyServer = class {
8
+ runtime = "bunny";
9
+ options;
10
+ fetch;
11
+ _started = false;
12
+ waitUntil;
13
+ constructor(options) {
14
+ this.options = {
15
+ ...options,
16
+ middleware: [...options.middleware || []]
17
+ };
18
+ for (const plugin of options.plugins || []) plugin(this);
19
+ errorPlugin(this);
20
+ const fetchHandler = wrapFetch(this);
21
+ const waitUntil = this.waitUntil = (p) => Bunny.unstable?.waitUntil?.(p);
22
+ this.fetch = (request) => {
23
+ Object.defineProperties(request, {
24
+ runtime: {
25
+ enumerable: true,
26
+ value: { name: "bunny" }
27
+ },
28
+ waitUntil: { value: waitUntil },
29
+ ip: {
30
+ enumerable: true,
31
+ get() {
32
+ return request.headers.get("x-real-ip");
33
+ }
34
+ }
35
+ });
36
+ return fetchHandler(request);
37
+ };
38
+ if (!options.manual) this.serve();
39
+ }
40
+ serve() {
41
+ if (typeof Bunny !== "undefined" && Bunny.v1?.serve) {
42
+ if (this._started) return;
43
+ this._started = true;
44
+ Bunny.v1.serve(this.fetch);
45
+ } else throw new Error("[srvx] Bunny runtime not detected.");
46
+ }
47
+ ready() {
48
+ return Promise.resolve(this);
49
+ }
50
+ close() {
51
+ return Promise.resolve();
52
+ }
53
+ };
54
+ export { FastResponse, FastURL, serve };
@@ -11,6 +11,7 @@ declare class DenoServer implements Server<DenoFetchHandler> {
11
11
  readonly deno: Server["deno"];
12
12
  readonly serveOptions: Deno.ServeTcpOptions | (Deno.ServeTcpOptions & Deno.TlsCertifiedKeyPem) | undefined;
13
13
  readonly fetch: DenoFetchHandler;
14
+ readonly waitUntil?: Server["waitUntil"];
14
15
  constructor(options: ServerOptions);
15
16
  serve(): Promise<this>;
16
17
  get url(): string | undefined;
@@ -11,6 +11,7 @@ var DenoServer = class {
11
11
  deno = {};
12
12
  serveOptions;
13
13
  fetch;
14
+ waitUntil;
14
15
  #listeningPromise;
15
16
  #listeningInfo;
16
17
  #wait;
@@ -29,6 +30,7 @@ var DenoServer = class {
29
30
  return;
30
31
  }
31
32
  this.#wait = createWaitUntil();
33
+ this.waitUntil = this.#wait.waitUntil;
32
34
  this.fetch = (request, info) => {
33
35
  Object.defineProperties(request, {
34
36
  waitUntil: { value: this.#wait?.waitUntil },
@@ -9,6 +9,7 @@ var GenericServer = class {
9
9
  runtime = "generic";
10
10
  options;
11
11
  fetch;
12
+ waitUntil;
12
13
  #wait;
13
14
  constructor(options) {
14
15
  this.options = {
@@ -18,6 +19,7 @@ var GenericServer = class {
18
19
  for (const plugin of options.plugins || []) plugin(this);
19
20
  errorPlugin(this);
20
21
  this.#wait = createWaitUntil();
22
+ this.waitUntil = this.#wait.waitUntil;
21
23
  const fetchHandler = wrapFetch(this);
22
24
  this.fetch = (request) => {
23
25
  Object.defineProperties(request, { waitUntil: { value: this.#wait.waitUntil } });
@@ -660,6 +660,7 @@ var NodeServer = class {
660
660
  node;
661
661
  serveOptions;
662
662
  fetch;
663
+ waitUntil;
663
664
  #isSecure;
664
665
  #listeningPromise;
665
666
  #wait;
@@ -678,6 +679,7 @@ var NodeServer = class {
678
679
  }
679
680
  gracefulShutdownPlugin(this);
680
681
  this.#wait = createWaitUntil();
682
+ this.waitUntil = this.#wait.waitUntil;
681
683
  const handler = (nodeReq, nodeRes) => {
682
684
  const request = new NodeRequest({
683
685
  req: nodeReq,
package/dist/cli.mjs CHANGED
@@ -174,7 +174,7 @@ function getResponseFormat(res) {
174
174
  }
175
175
  const srvxMeta = {
176
176
  name: "srvx",
177
- version: "0.11.3",
177
+ version: "0.11.6",
178
178
  description: "Universal Server."
179
179
  };
180
180
  function usage(mainOpts) {
package/dist/types.d.mts CHANGED
@@ -154,7 +154,7 @@ interface Server<Handler = ServerHandler> {
154
154
  /**
155
155
  * Current runtime name
156
156
  */
157
- readonly runtime: "node" | "deno" | "bun" | "cloudflare" | "service-worker" | "aws-lambda" | "generic";
157
+ readonly runtime: "node" | "deno" | "bun" | "bunny" | "cloudflare" | "service-worker" | "aws-lambda" | "generic";
158
158
  /**
159
159
  * Server options
160
160
  */
@@ -198,6 +198,12 @@ interface Server<Handler = ServerHandler> {
198
198
  */
199
199
  ready(): Promise<Server<Handler>>;
200
200
  /**
201
+ * Register a background task that the server should await before closing.
202
+ *
203
+ * Same as `request.waitUntil` but available at the server level for use outside of request handlers.
204
+ */
205
+ readonly waitUntil?: (promise: Promise<unknown>) => void;
206
+ /**
201
207
  * Stop listening to prevent new connections from being accepted.
202
208
  *
203
209
  * By default, it does not cancel in-flight requests or websockets. That means it may take some time before all network activity stops.
@@ -208,7 +214,7 @@ interface Server<Handler = ServerHandler> {
208
214
  close(closeActiveConnections?: boolean): Promise<void>;
209
215
  }
210
216
  interface ServerRuntimeContext {
211
- name: "node" | "deno" | "bun" | "cloudflare" | "aws-lambda" | (string & {});
217
+ name: "node" | "deno" | "bun" | "bunny" | "cloudflare" | "aws-lambda" | (string & {});
212
218
  /**
213
219
  * Underlying Node.js server request info.
214
220
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srvx",
3
- "version": "0.11.4",
3
+ "version": "0.11.6",
4
4
  "description": "Universal Server.",
5
5
  "homepage": "https://srvx.h3.dev",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@
20
20
  "./bun": "./dist/adapters/bun.mjs",
21
21
  "./node": "./dist/adapters/node.mjs",
22
22
  "./cloudflare": "./dist/adapters/cloudflare.mjs",
23
+ "./bunny": "./dist/adapters/bunny.mjs",
23
24
  "./generic": "./dist/adapters/generic.mjs",
24
25
  "./service-worker": "./dist/adapters/service-worker.mjs",
25
26
  "./aws-lambda": "./dist/adapters/aws-lambda.mjs",
@@ -58,18 +59,18 @@
58
59
  "vitest": "vitest"
59
60
  },
60
61
  "devDependencies": {
61
- "@cloudflare/workers-types": "^4.20260210.0",
62
+ "@cloudflare/workers-types": "^4.20260217.0",
62
63
  "@hono/node-server": "^1.19.9",
63
64
  "@mitata/counters": "^0.0.8",
64
65
  "@mjackson/node-fetch-server": "^0.7.0",
65
66
  "@types/aws-lambda": "^8.10.160",
66
- "@types/bun": "^1.3.8",
67
+ "@types/bun": "^1.3.9",
67
68
  "@types/deno": "^2.5.0",
68
69
  "@types/express": "^5.0.6",
69
70
  "@types/node": "^25.2.3",
70
71
  "@types/node-forge": "^1.3.14",
71
- "@types/serviceworker": "^0.0.186",
72
- "@typescript/native-preview": "^7.0.0-dev.20260210.1",
72
+ "@types/serviceworker": "^0.0.191",
73
+ "@typescript/native-preview": "^7.0.0-dev.20260217.1",
73
74
  "@vitest/coverage-v8": "^4.0.18",
74
75
  "@whatwg-node/server": "^0.10.18",
75
76
  "automd": "^0.4.3",
@@ -83,12 +84,12 @@
83
84
  "mitata": "^1.0.34",
84
85
  "node-forge": "^1.3.3",
85
86
  "obuild": "^0.4.27",
86
- "oxfmt": "^0.28.0",
87
- "oxlint": "^1.43.0",
88
- "srvx-release": "npm:srvx@^0.10.1",
87
+ "oxfmt": "^0.33.0",
88
+ "oxlint": "^1.48.0",
89
+ "srvx-release": "npm:srvx@^0.11.4",
89
90
  "tslib": "^2.8.1",
90
91
  "typescript": "^5.9.3",
91
- "undici": "^7.21.0",
92
+ "undici": "^7.22.0",
92
93
  "vitest": "^4.0.18"
93
94
  },
94
95
  "resolutions": {
@@ -97,5 +98,5 @@
97
98
  "engines": {
98
99
  "node": ">=20.16.0"
99
100
  },
100
- "packageManager": "pnpm@10.29.2"
101
+ "packageManager": "pnpm@10.29.3"
101
102
  }