srvx 0.8.6 → 0.8.7

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.
@@ -181,6 +181,11 @@ interface Server<Handler = ServerHandler> {
181
181
  */
182
182
  readonly fetch: Handler;
183
183
  /**
184
+ * Start listening for incoming requests.
185
+ * When `manual` option is enabled, this method needs to be called explicitly to begin accepting connections.
186
+ */
187
+ serve(): void | Promise<Server<Handler>>;
188
+ /**
184
189
  * Returns a promise that resolves when the server is ready.
185
190
  */
186
191
  ready(): Promise<Server<Handler>>;
@@ -226,6 +231,9 @@ interface ServerRuntimeContext {
226
231
  env: IsAny<typeof cloudflare_workers0> extends true ? Record<string, unknown> : typeof cloudflare_workers0.env;
227
232
  };
228
233
  }
234
+ interface ServerRequestContext {
235
+ [key: string]: unknown;
236
+ }
229
237
  interface ServerRequest extends Request {
230
238
  /**
231
239
  * Runtime specific request context.
@@ -236,6 +244,10 @@ interface ServerRequest extends Request {
236
244
  */
237
245
  ip?: string | undefined;
238
246
  /**
247
+ * Arbitrary context related to the request.
248
+ */
249
+ context?: ServerRequestContext;
250
+ /**
239
251
  * Tell the runtime about an ongoing operation that shouldn't close until the promise resolves.
240
252
  */
241
253
  waitUntil?: (promise: Promise<unknown>) => void | Promise<void>;
@@ -253,4 +265,4 @@ type NodeHttpHandler = (req: NodeServerRequest, res: NodeServerResponse) => void
253
265
  type NodeHTTPMiddleware = (req: NodeServerRequest, res: NodeServerResponse, next: (error?: Error) => void) => unknown | Promise<unknown>;
254
266
  type CloudflareFetchHandler = CF.ExportedHandlerFetchHandler;
255
267
  //#endregion
256
- export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve };
268
+ export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve };
@@ -1,4 +1,4 @@
1
- import { BunFetchHandler, Server, ServerOptions } from "../_chunks/types-BXtbU5Z8.mjs";
1
+ import { BunFetchHandler, Server, ServerOptions } from "../_chunks/types-BtByT9ny.mjs";
2
2
  import { FastURL$2 as FastURL } from "../_chunks/_url-D8u5OAto.mjs";
3
3
  import * as bun from "bun";
4
4
 
@@ -1,4 +1,4 @@
1
- import { Server, ServerOptions } from "../_chunks/types-BXtbU5Z8.mjs";
1
+ import { Server, ServerOptions } from "../_chunks/types-BtByT9ny.mjs";
2
2
  import * as CF from "@cloudflare/workers-types";
3
3
 
4
4
  //#region src/adapters/cloudflare.d.ts
@@ -1,4 +1,4 @@
1
- import { DenoFetchHandler, Server, ServerOptions } from "../_chunks/types-BXtbU5Z8.mjs";
1
+ import { DenoFetchHandler, Server, ServerOptions } from "../_chunks/types-BtByT9ny.mjs";
2
2
  import { FastURL$2 as FastURL } from "../_chunks/_url-D8u5OAto.mjs";
3
3
 
4
4
  //#region src/adapters/deno.d.ts
@@ -1,4 +1,4 @@
1
- import { Server, ServerOptions } from "../_chunks/types-BXtbU5Z8.mjs";
1
+ import { Server, ServerOptions } from "../_chunks/types-BtByT9ny.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-BXtbU5Z8.mjs";
1
+ import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest } from "../_chunks/types-BtByT9ny.mjs";
2
2
  import { FastURL$2 as FastURL } from "../_chunks/_url-D8u5OAto.mjs";
3
3
  import NodeHttp from "node:http";
4
4
  import { Readable } from "node:stream";
@@ -1,4 +1,4 @@
1
- import { Server, ServerOptions, ServerRequest } from "../_chunks/types-BXtbU5Z8.mjs";
1
+ import { Server, ServerOptions, ServerRequest } from "../_chunks/types-BtByT9ny.mjs";
2
2
 
3
3
  //#region src/adapters/service-worker.d.ts
4
4
  declare const FastURL: typeof globalThis.URL;
package/dist/cli.mjs CHANGED
@@ -216,7 +216,7 @@ async function interceptListen(cb) {
216
216
  };
217
217
  }
218
218
  async function version() {
219
- const version$1 = "0.8.6";
219
+ const version$1 = "0.8.7";
220
220
  return `srvx ${version$1}\n${runtime()}`;
221
221
  }
222
222
  function runtime() {
package/dist/log.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ServerMiddleware } from "./_chunks/types-BXtbU5Z8.mjs";
1
+ import { ServerMiddleware } from "./_chunks/types-BtByT9ny.mjs";
2
2
 
3
3
  //#region src/log.d.ts
4
4
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
package/dist/static.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ServerMiddleware } from "./_chunks/types-BXtbU5Z8.mjs";
1
+ import { ServerMiddleware } from "./_chunks/types-BtByT9ny.mjs";
2
2
 
3
3
  //#region src/static.d.ts
4
4
  interface ServeStaticOptions {
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve } from "./_chunks/types-BXtbU5Z8.mjs";
2
- export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve };
1
+ import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve } from "./_chunks/types-BtByT9ny.mjs";
2
+ export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srvx",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
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",
@@ -39,12 +39,11 @@
39
39
  "bench:node": "node test/bench-node/_run.mjs",
40
40
  "bench:url:bun": "bun run ./test/url.bench.ts",
41
41
  "bench:url:deno": "deno run -A ./test/url.bench.ts",
42
- "bench:url:node": "pnpm node-ts --expose-gc --allow-natives-syntax ./test/url.bench.ts",
42
+ "bench:url:node": "pnpm --expose-gc --allow-natives-syntax ./test/url.bench.ts",
43
43
  "build": "obuild",
44
44
  "dev": "vitest dev",
45
45
  "lint": "eslint . && prettier -c .",
46
46
  "lint:fix": "automd && eslint . --fix && prettier -w .",
47
- "node-ts": "node --disable-warning=ExperimentalWarning --experimental-strip-types",
48
47
  "prepack": "pnpm build",
49
48
  "play:mkcert": "openssl req -x509 -newkey rsa:2048 -nodes -keyout server.key -out server.crt -days 365 -subj /CN=srvx.local",
50
49
  "release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",