| import { a as green, i as gray, n as bold, s as red } from "./_utils.mjs"; | ||
| //#region src/_middleware.ts | ||
| function wrapFetch(server) { | ||
@@ -12,4 +11,2 @@ const fetchHandler = server.options.fetch; | ||
| } | ||
| //#endregion | ||
| //#region src/_plugins.ts | ||
| const errorPlugin = (server) => { | ||
@@ -60,3 +57,2 @@ const errorHandler = server.options.error; | ||
| }; | ||
| //#endregion | ||
| export { gracefulShutdownPlugin as n, wrapFetch as r, errorPlugin as t }; |
@@ -1,2 +0,1 @@ | ||
| //#region src/_url.d.ts | ||
| type URLInit = { | ||
@@ -27,3 +26,2 @@ protocol: string; | ||
| }; | ||
| //#endregion | ||
| export { FastURL as t }; |
@@ -1,2 +0,1 @@ | ||
| //#region src/_inherit.ts | ||
| function lazyInherit(target, source, sourceKey) { | ||
@@ -29,19 +28,3 @@ for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) { | ||
| } | ||
| //#endregion | ||
| //#region src/_url.ts | ||
| const _needsNormRE = /(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^\x80-\uffff]/i; | ||
| /** | ||
| * URL wrapper with fast paths to access to the following props: | ||
| * | ||
| * - `url.pathname` | ||
| * - `url.search` | ||
| * - `url.searchParams` | ||
| * - `url.protocol` | ||
| * | ||
| * **NOTES:** | ||
| * | ||
| * - It is assumed that the input URL is **already encoded** and formatted from an HTTP request and contains no hash. | ||
| * - Triggering the setters or getters on other props will deoptimize to full URL parsing. | ||
| * - Changes to `searchParams` will be discarded as we don't track them. | ||
| */ | ||
| const FastURL = /* @__PURE__ */ (() => { | ||
@@ -94,6 +77,7 @@ const NativeURL = globalThis.URL; | ||
| const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4); | ||
| const qIndex = pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex); | ||
| this.#pos = [ | ||
| protoIndex, | ||
| pathnameIndex, | ||
| pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex) | ||
| qIndex | ||
| ]; | ||
@@ -132,3 +116,4 @@ } | ||
| if (protocolIndex === -1) return this._url.protocol; | ||
| this.#protocol = this.href.slice(0, protocolIndex + 1); | ||
| const url = this.href; | ||
| this.#protocol = url.slice(0, protocolIndex + 1); | ||
| } | ||
@@ -149,3 +134,2 @@ return this.#protocol; | ||
| })(); | ||
| //#endregion | ||
| export { lazyInherit as n, FastURL as t }; |
@@ -1,2 +0,1 @@ | ||
| //#region src/cli/_utils.ts | ||
| const noColor = /* @__PURE__ */ (() => { | ||
@@ -16,3 +15,2 @@ const env = globalThis.process?.env ?? {}; | ||
| const url = (title, url) => noColor ? `[${title}](${url})` : `\u001B]8;;${url}\u001B\\${title}\u001B]8;;\u001B\\`; | ||
| //#endregion | ||
| export { green as a, url as c, gray as i, yellow as l, bold as n, magenta as o, cyan as r, red as s, blue as t }; |
@@ -1,2 +0,1 @@ | ||
| //#region src/_utils.ts | ||
| function resolvePortAndHost(opts) { | ||
@@ -71,3 +70,2 @@ const _port = opts.port ?? globalThis.process?.env.PORT ?? 3e3; | ||
| } | ||
| //#endregion | ||
| export { resolveTLSOptions as a, resolvePortAndHost as i, fmtURL as n, printListening as r, createWaitUntil as t }; |
| import { Server, ServerHandler } from "srvx"; | ||
| //#region src/loader.d.ts | ||
| declare const defaultExts: string[]; | ||
@@ -86,3 +84,2 @@ declare const defaultEntries: string[]; | ||
| type NodeServer = NonNullable<Server["node"]>["server"]; | ||
| //#endregion | ||
| export { loadServerEntry as a, defaultExts as i, LoadedServerEntry as n, defaultEntries as r, LoadOptions as t }; |
| import { FetchHandler, ServerOptions } from "../types.mjs"; | ||
| import * as AWS from "aws-lambda"; | ||
| //#region src/adapters/_aws/utils.d.ts | ||
| type AWSLambdaResponseStream = NodeJS.WritableStream & { | ||
| setContentType(contentType: string): void; | ||
| }; | ||
| //#endregion | ||
| //#region src/adapters/aws-lambda.d.ts | ||
| type MaybePromise<T> = T | Promise<T>; | ||
@@ -18,3 +14,2 @@ type AwsLambdaEvent = AWS.APIGatewayProxyEvent | AWS.APIGatewayProxyEventV2; | ||
| declare function invokeLambdaHandler(handler: AWSLambdaHandler, request: Request): Promise<Response>; | ||
| //#endregion | ||
| export { AWSLambdaHandler, type AWSLambdaResponseStream, AWSLambdaStreamingHandler, AwsLambdaEvent, handleLambdaEvent, handleLambdaEventWithStream, invokeLambdaHandler, toLambdaHandler }; |
| import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/_aws/utils.ts | ||
| function awsRequest(event, context) { | ||
@@ -79,8 +78,8 @@ const req = new Request(awsEventURL(event), { | ||
| const writer = globalThis.awslambda.HttpResponseStream.from(responseStream, metadata); | ||
| if (!response.body) { | ||
| writer.end(); | ||
| return; | ||
| } | ||
| const body = response.body ?? new ReadableStream({ start(controller) { | ||
| controller.enqueue(""); | ||
| controller.close(); | ||
| } }); | ||
| try { | ||
| await streamToNodeStream(response.body, writer); | ||
| await streamToNodeStream(body, writer); | ||
| } finally { | ||
@@ -254,4 +253,2 @@ writer.end(); | ||
| } | ||
| //#endregion | ||
| //#region src/adapters/aws-lambda.ts | ||
| function toLambdaHandler(options) { | ||
@@ -297,3 +294,2 @@ const server = new AWSLambdaServer(options); | ||
| }; | ||
| //#endregion | ||
| export { handleLambdaEvent, handleLambdaEventWithStream, invokeLambdaHandler, toLambdaHandler }; |
| import { BunFetchHandler, Server, ServerOptions } from "../types.mjs"; | ||
| import { t as FastURL } from "../_chunks/_url.mjs"; | ||
| import * as bun from "bun"; | ||
| //#region src/adapters/bun.d.ts | ||
| declare const FastResponse: typeof globalThis.Response; | ||
@@ -22,3 +20,2 @@ declare function serve(options: ServerOptions): BunServer; | ||
| } | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { t as FastURL } from "../_chunks/_url.mjs"; | ||
| import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs"; | ||
| import { n as gracefulShutdownPlugin, r as wrapFetch } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/bun.ts | ||
| const FastResponse = Response; | ||
@@ -87,3 +86,2 @@ function serve(options) { | ||
| }; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { Server, ServerOptions } from "../types.mjs"; | ||
| //#region src/adapters/bunny.d.ts | ||
| declare const FastURL: typeof globalThis.URL; | ||
| declare const FastResponse: typeof globalThis.Response; | ||
| declare function serve(options: ServerOptions): Server; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/bunny.ts | ||
| const FastURL = URL; | ||
@@ -55,3 +54,2 @@ const FastResponse = Response; | ||
| }; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { Server, ServerOptions } from "../types.mjs"; | ||
| import * as CF from "@cloudflare/workers-types"; | ||
| //#region src/adapters/cloudflare.d.ts | ||
| declare const FastURL: typeof globalThis.URL; | ||
| declare const FastResponse: typeof globalThis.Response; | ||
| declare function serve(options: ServerOptions): Server<CF.ExportedHandlerFetchHandler>; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/cloudflare.ts | ||
| const FastURL = URL; | ||
@@ -58,3 +57,2 @@ const FastResponse = Response; | ||
| }; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { DenoFetchHandler, Server, ServerOptions } from "../types.mjs"; | ||
| import { t as FastURL } from "../_chunks/_url.mjs"; | ||
| //#region src/adapters/deno.d.ts | ||
| declare const FastResponse: typeof globalThis.Response; | ||
@@ -21,3 +19,2 @@ declare function serve(options: ServerOptions): DenoServer; | ||
| } | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { t as FastURL } from "../_chunks/_url.mjs"; | ||
| import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs"; | ||
| import { n as gracefulShutdownPlugin, r as wrapFetch } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/deno.ts | ||
| const FastResponse = Response; | ||
@@ -96,3 +95,2 @@ function serve(options) { | ||
| }; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { Server, ServerOptions } from "../types.mjs"; | ||
| //#region src/adapters/generic.d.ts | ||
| declare const FastURL: typeof globalThis.URL; | ||
| declare const FastResponse: typeof globalThis.Response; | ||
| declare function serve(options: ServerOptions): Server; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { t as createWaitUntil } from "../_chunks/_utils2.mjs"; | ||
| import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/generic.ts | ||
| const FastURL = URL; | ||
@@ -38,3 +37,2 @@ const FastResponse = Response; | ||
| }; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
| import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest } from "../types.mjs"; | ||
| import { t as FastURL } from "../_chunks/_url.mjs"; | ||
| import { Readable } from "node:stream"; | ||
| //#region src/adapters/_node/request.d.ts | ||
| type NodeRequestContext = { | ||
@@ -21,4 +19,2 @@ req: NodeServerRequest; | ||
| declare function patchGlobalRequest(): typeof Request; | ||
| //#endregion | ||
| //#region src/adapters/_node/response.d.ts | ||
| type PreparedNodeResponseBody = string | Buffer | Uint8Array | DataView | ReadableStream | Readable | undefined | null; | ||
@@ -42,7 +38,3 @@ interface PreparedNodeResponse { | ||
| type NodeResponse = InstanceType<typeof NodeResponse>; | ||
| //#endregion | ||
| //#region src/adapters/_node/send.d.ts | ||
| declare function sendNodeResponse(nodeRes: NodeServerResponse, webRes: Response | NodeResponse): Promise<void>; | ||
| //#endregion | ||
| //#region src/adapters/_node/web/fetch.d.ts | ||
| /** | ||
@@ -60,4 +52,2 @@ * Calls a Node.js HTTP Request handler with a Fetch API Request object and returns a Response object. | ||
| declare function fetchNodeHandler(handler: NodeHttpHandler, req: ServerRequest): Promise<Response>; | ||
| //#endregion | ||
| //#region src/adapters/_node/adapter.d.ts | ||
| type AdapterMeta = { | ||
@@ -77,6 +67,3 @@ __nodeHandler?: NodeHttpHandler; | ||
| declare function toFetchHandler(handler: NodeHttpHandler & AdapterMeta): FetchHandler & AdapterMeta; | ||
| //#endregion | ||
| //#region src/adapters/node.d.ts | ||
| declare function serve(options: ServerOptions): Server; | ||
| //#endregion | ||
| export { type AdapterMeta, NodeResponse as FastResponse, NodeResponse, FastURL, NodeRequest, fetchNodeHandler, patchGlobalRequest, sendNodeResponse, serve, toFetchHandler, toNodeHandler }; |
+31
-76
@@ -9,3 +9,2 @@ import { n as lazyInherit, t as FastURL } from "../_chunks/_url.mjs"; | ||
| import nodeHTTP2 from "node:http2"; | ||
| //#region src/adapters/_node/send.ts | ||
| async function sendNodeResponse(nodeRes, webRes) { | ||
@@ -33,3 +32,3 @@ if (!webRes) { | ||
| function writeHead(nodeRes, status, statusText, rawHeaders) { | ||
| const writeHeaders = globalThis.Deno ? rawHeaders : rawHeaders.flat(); | ||
| const writeHeaders = rawHeaders.flat(); | ||
| if (!nodeRes.headersSent) if (nodeRes.req?.httpVersion === "2.0") nodeRes.writeHead(status, writeHeaders); | ||
@@ -102,8 +101,2 @@ else nodeRes.writeHead(status, statusText, writeHeaders); | ||
| } | ||
| //#endregion | ||
| //#region src/adapters/_node/url.ts | ||
| /** | ||
| * Validates an HTTP Host header value (domain, IPv4, or bracketed IPv6) with optional port. | ||
| * Intended for preliminary filtering invalid values like "localhost:3000/foobar?" | ||
| */ | ||
| const HOST_RE = /^(\[(?:[A-Fa-f0-9:.]+)\]|(?:[A-Za-z0-9_-]+\.)*[A-Za-z0-9_-]+|(?:\d{1,3}\.){3}\d{1,3})(:\d{1,5})?$/; | ||
@@ -114,18 +107,22 @@ var NodeRequestURL = class extends FastURL { | ||
| const path = req.url || "/"; | ||
| let host = req.headers.host || req.headers[":authority"]; | ||
| if (host && !HOST_RE.test(host)) host = "_invalid_"; | ||
| else if (!host) if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`; | ||
| else host = "localhost"; | ||
| const protocol = req.socket?.encrypted || req.headers["x-forwarded-proto"] === "https" || req.headers[":scheme"] === "https" ? "https:" : "http:"; | ||
| if (path[0] === "/") { | ||
| const qIndex = path.indexOf("?"); | ||
| const pathname = qIndex === -1 ? path : path?.slice(0, qIndex) || "/"; | ||
| const search = qIndex === -1 ? "" : path?.slice(qIndex) || ""; | ||
| let host = req.headers.host || req.headers[":authority"]; | ||
| if (host && !HOST_RE.test(host)) host = "_invalid_"; | ||
| else if (!host) if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`; | ||
| else host = "localhost"; | ||
| const protocol = req.socket?.encrypted || req.headers["x-forwarded-proto"] === "https" || req.headers[":scheme"] === "https" ? "https:" : "http:"; | ||
| super({ | ||
| protocol, | ||
| host, | ||
| pathname, | ||
| search | ||
| pathname: qIndex === -1 ? path : path.slice(0, qIndex) || "/", | ||
| search: qIndex === -1 ? "" : path.slice(qIndex) || "" | ||
| }); | ||
| } else super(path); | ||
| } else if (path === "*") super({ | ||
| protocol, | ||
| host, | ||
| pathname: "/*", | ||
| search: "" | ||
| }); | ||
| else super(path); | ||
| this.#req = req; | ||
@@ -141,4 +138,2 @@ } | ||
| }; | ||
| //#endregion | ||
| //#region src/adapters/_node/headers.ts | ||
| const NodeRequestHeaders = /* @__PURE__ */ (() => { | ||
@@ -196,4 +191,2 @@ const NativeHeaders = globalThis.Headers; | ||
| })(); | ||
| //#endregion | ||
| //#region src/adapters/_node/request.ts | ||
| const NodeRequest = /* @__PURE__ */ (() => { | ||
@@ -264,3 +257,4 @@ const NativeRequest = globalThis.Request; | ||
| const method = this.method; | ||
| this.#bodyStream = !(method === "GET" || method === "HEAD") ? Readable.toWeb(this.#req) : null; | ||
| const hasBody = !(method === "GET" || method === "HEAD"); | ||
| this.#bodyStream = hasBody ? Readable.toWeb(this.#req) : null; | ||
| } | ||
@@ -298,9 +292,2 @@ return this.#bodyStream; | ||
| })(); | ||
| /** | ||
| * Undici uses an incompatible Request constructor depending on private property accessors. | ||
| * | ||
| * This utility, patches global Request to support `new Request(req)` in Node.js. | ||
| * | ||
| * Alternatively you can use `new Request(req._request || req)` instead of patching global Request. | ||
| */ | ||
| function patchGlobalRequest() { | ||
@@ -340,9 +327,2 @@ const NativeRequest = globalThis[Symbol.for("srvx.nativeRequest")] ??= globalThis.Request; | ||
| } | ||
| //#endregion | ||
| //#region src/adapters/_node/response.ts | ||
| /** | ||
| * Fast Response for Node.js runtime | ||
| * | ||
| * It is faster because in most cases it doesn't create a full Response instance. | ||
| */ | ||
| const NodeResponse = /* @__PURE__ */ (() => { | ||
@@ -456,9 +436,2 @@ const NativeResponse = globalThis.Response; | ||
| })(); | ||
| //#endregion | ||
| //#region src/adapters/_node/web/socket.ts | ||
| /** | ||
| * Events: | ||
| * - Readable (req from client): readable => data => end (push(null)) => error => close | ||
| * - Writable (res to client): pipe => unpipe => drain => finish (end called) => error => close | ||
| */ | ||
| var WebRequestSocket = class extends Duplex { | ||
@@ -482,2 +455,3 @@ _httpMessage; | ||
| _webResBody; | ||
| #tos = 0; | ||
| constructor(request) { | ||
@@ -540,2 +514,9 @@ super({ | ||
| } | ||
| getTypeOfService() { | ||
| return this.#tos; | ||
| } | ||
| setTypeOfService(tos) { | ||
| this.#tos = tos; | ||
| return this; | ||
| } | ||
| _read(_size) { | ||
@@ -588,4 +569,2 @@ const reader = this.#reqReader ??= this.bodyReader(); | ||
| }; | ||
| //#endregion | ||
| //#region src/adapters/_node/web/incoming.ts | ||
| var WebIncomingMessage = class extends IncomingMessage { | ||
@@ -609,4 +588,2 @@ constructor(req, socket) { | ||
| }; | ||
| //#endregion | ||
| //#region src/adapters/_node/call.ts | ||
| function callNodeHandler(handler, req) { | ||
@@ -655,4 +632,2 @@ const isMiddleware = handler.length > 2; | ||
| } | ||
| //#endregion | ||
| //#region src/adapters/_node/web/response.ts | ||
| var WebServerResponse = class extends ServerResponse { | ||
@@ -696,15 +671,2 @@ #socket; | ||
| }; | ||
| //#endregion | ||
| //#region src/adapters/_node/web/fetch.ts | ||
| /** | ||
| * Calls a Node.js HTTP Request handler with a Fetch API Request object and returns a Response object. | ||
| * | ||
| * If the web Request contains an existing Node.js req/res pair (indicating it originated from a Node.js server from srvx/node), it will be called directly. | ||
| * | ||
| * Otherwise, new Node.js IncomingMessage and ServerResponse objects are created and linked to a custom Duplex stream that bridges the Fetch API streams with Node.js streams. | ||
| * | ||
| * The handler is invoked with these objects, and the response is constructed from the ServerResponse once it is finished. | ||
| * | ||
| * @experimental Behavior might be unstable. | ||
| */ | ||
| async function fetchNodeHandler(handler, req) { | ||
@@ -730,7 +692,2 @@ const nodeRuntime = req.runtime?.node; | ||
| } | ||
| //#endregion | ||
| //#region src/adapters/_node/adapter.ts | ||
| /** | ||
| * Converts a Fetch API handler to a Node.js HTTP handler. | ||
| */ | ||
| function toNodeHandler(handler) { | ||
@@ -749,7 +706,2 @@ if (handler.__nodeHandler) return handler.__nodeHandler; | ||
| } | ||
| /** | ||
| * Converts a Node.js HTTP handler into a Fetch API handler. | ||
| * | ||
| * @experimental Behavior might be unstable and won't work in Bun and Deno currently (tracker: https://github.com/h3js/srvx/issues/132) | ||
| */ | ||
| function toFetchHandler(handler) { | ||
@@ -769,4 +721,2 @@ if (handler.__fetchHandler) return handler.__fetchHandler; | ||
| } | ||
| //#endregion | ||
| //#region src/adapters/node.ts | ||
| function serve(options) { | ||
@@ -795,2 +745,8 @@ return new NodeServer(options); | ||
| const handler = (nodeReq, nodeRes) => { | ||
| const reqUrl = nodeReq.url; | ||
| if (reqUrl && reqUrl[0] !== "/" && reqUrl !== "*" && !URL.canParse(reqUrl)) { | ||
| nodeRes.statusCode = 400; | ||
| nodeRes.end(); | ||
| return; | ||
| } | ||
| const request = new NodeRequest({ | ||
@@ -882,3 +838,2 @@ req: nodeReq, | ||
| }; | ||
| //#endregion | ||
| export { NodeResponse as FastResponse, NodeResponse, FastURL, NodeRequest, fetchNodeHandler, patchGlobalRequest, sendNodeResponse, serve, toFetchHandler, toNodeHandler }; |
| import { Server, ServerOptions, ServerRequest } from "../types.mjs"; | ||
| //#region src/adapters/service-worker.d.ts | ||
| declare const FastURL: typeof globalThis.URL; | ||
@@ -8,3 +6,2 @@ declare const FastResponse: typeof globalThis.Response; | ||
| declare function serve(options: ServerOptions): Server<ServiceWorkerHandler>; | ||
| //#endregion | ||
| export { FastResponse, FastURL, ServiceWorkerHandler, serve }; |
| import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs"; | ||
| //#region src/adapters/service-worker.ts | ||
| const FastURL = URL; | ||
| const FastResponse = Response; | ||
| const isBrowserWindow = typeof window !== "undefined" && typeof navigator !== "undefined"; | ||
| const isServiceWorker = typeof self !== "undefined" && "skipWaiting" in self; | ||
| const isServiceWorker = /* @__PURE__ */ (() => typeof self !== "undefined" && "skipWaiting" in self)(); | ||
| function serve(options) { | ||
@@ -77,3 +76,2 @@ return new ServiceWorkerServer(options); | ||
| }; | ||
| //#endregion | ||
| export { FastResponse, FastURL, serve }; |
+0
-7
| import { t as LoadOptions } from "./_chunks/loader.mjs"; | ||
| //#region src/cli/types.d.ts | ||
| type MainOptions = CLIOptions & { | ||
@@ -41,7 +39,3 @@ args?: string[]; | ||
| }; | ||
| //#endregion | ||
| //#region src/cli/main.d.ts | ||
| declare function main(mainOpts: MainOptions): Promise<void>; | ||
| //#endregion | ||
| //#region src/cli/fetch.d.ts | ||
| declare function cliFetch(cliOpts: CLIOptions & LoadOptions & { | ||
@@ -53,3 +47,2 @@ loader?: LoadOptions; | ||
| }): Promise<Response>; | ||
| //#endregion | ||
| export { type CLIOptions, type MainOptions, cliFetch, main }; |
+0
-10
@@ -9,3 +9,2 @@ import { a as green, c as url, i as gray, l as yellow, n as bold, o as magenta, r as cyan, s as red } from "./_chunks/_utils.mjs"; | ||
| import { Readable } from "node:stream"; | ||
| //#region src/cli/serve.ts | ||
| const NO_ENTRY_ERROR = "No server entry or public directory found"; | ||
@@ -93,4 +92,2 @@ async function cliServe(cliOpts) { | ||
| } | ||
| //#endregion | ||
| //#region src/cli/fetch.ts | ||
| async function cliFetch(cliOpts) { | ||
@@ -185,4 +182,2 @@ const stdin = cliOpts.stdin || process.stdin; | ||
| } | ||
| //#endregion | ||
| //#region src/cli/_meta.ts | ||
| const srvxMeta = { | ||
@@ -193,4 +188,2 @@ name: "srvx", | ||
| }; | ||
| //#endregion | ||
| //#region src/cli/usage.ts | ||
| function usage(mainOpts) { | ||
@@ -261,4 +254,2 @@ const command = mainOpts.usage?.command || "srvx"; | ||
| } | ||
| //#endregion | ||
| //#region src/cli/main.ts | ||
| async function main(mainOpts) { | ||
@@ -440,3 +431,2 @@ const args = process.argv.slice(2); | ||
| } | ||
| //#endregion | ||
| export { cliFetch, main }; |
+0
-2
@@ -6,3 +6,2 @@ import { pathToFileURL } from "node:url"; | ||
| import { EventEmitter } from "node:events"; | ||
| //#region src/loader.ts | ||
| const defaultExts = [ | ||
@@ -140,3 +139,2 @@ ".mjs", | ||
| }; | ||
| //#endregion | ||
| export { defaultEntries, defaultExts, loadServerEntry }; |
+0
-3
| import { ServerMiddleware } from "./types.mjs"; | ||
| //#region src/log.d.ts | ||
| interface LogOptions {} | ||
| declare const log: (options?: LogOptions) => ServerMiddleware; | ||
| //#endregion | ||
| export { LogOptions, log }; |
+0
-2
| import { a as green, i as gray, l as yellow, n as bold, s as red, t as blue } from "./_chunks/_utils.mjs"; | ||
| //#region src/log.ts | ||
| const statusColors = { | ||
@@ -18,3 +17,2 @@ 1: blue, | ||
| }; | ||
| //#endregion | ||
| export { log }; |
| import { ServerMiddleware } from "./types.mjs"; | ||
| //#region src/static.d.ts | ||
| interface ServeStaticOptions { | ||
@@ -23,3 +21,2 @@ /** | ||
| declare const serveStatic: (options: ServeStaticOptions) => ServerMiddleware; | ||
| //#endregion | ||
| export { ServeStaticOptions, serveStatic }; |
+0
-2
@@ -7,3 +7,2 @@ import { t as FastURL } from "./_chunks/_url.mjs"; | ||
| import { createBrotliCompress, createGzip } from "node:zlib"; | ||
| //#region src/static.ts | ||
| const COMMON_MIME_TYPES = { | ||
@@ -76,3 +75,2 @@ ".html": "text/html", | ||
| }; | ||
| //#endregion | ||
| export { serveStatic }; |
| import { Server, ServerMiddleware, ServerPlugin, ServerRequest } from "./types.mjs"; | ||
| //#region src/tracing.d.ts | ||
| /** | ||
@@ -40,3 +38,2 @@ * @experimental Channel names, event types and config options may change in future releases. | ||
| }): ServerPlugin; | ||
| //#endregion | ||
| export { RequestEvent, tracingPlugin }; |
+0
-23
@@ -1,23 +0,1 @@ | ||
| //#region src/tracing.ts | ||
| /** | ||
| * | ||
| * @experimental Channel names, event types and config options may change in future releases. | ||
| * | ||
| * Tracing plugin that adds diagnostics channel tracing to middleware and fetch handlers. | ||
| * | ||
| * This plugin wraps all middleware and the fetch handler with tracing instrumentation, | ||
| * allowing you to subscribe to `srvx.request` and `srvx.middleware` tracing channels. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { serve } from "srvx"; | ||
| * import { tracingPlugin } from "srvx/tracing"; | ||
| * | ||
| * const server = serve({ | ||
| * fetch: (req) => new Response("OK"), | ||
| * middleware: [myMiddleware], | ||
| * plugins: [tracingPlugin()], | ||
| * }); | ||
| * ``` | ||
| */ | ||
| function tracingPlugin(opts = {}) { | ||
@@ -56,3 +34,2 @@ return (server) => { | ||
| } | ||
| //#endregion | ||
| export { tracingPlugin }; |
+1
-5
@@ -5,8 +5,5 @@ import * as NodeHttp from "node:http"; | ||
| import * as AWS from "aws-lambda"; | ||
| import * as cloudflare_workers0 from "cloudflare:workers"; | ||
| import * as NodeNet from "node:net"; | ||
| import * as Bun from "bun"; | ||
| import * as CF from "@cloudflare/workers-types"; | ||
| //#region src/types.d.ts | ||
| type MaybePromise<T> = T | Promise<T>; | ||
@@ -243,3 +240,3 @@ type IsAny<T> = Equal<T, any> extends true ? true : false; | ||
| context: CF.ExecutionContext; | ||
| env: IsAny<typeof cloudflare_workers0> extends true ? Record<string, unknown> : typeof cloudflare_workers0.env; | ||
| env: IsAny<typeof import("cloudflare:workers")> extends true ? Record<string, unknown> : typeof import("cloudflare:workers").env; | ||
| }; | ||
@@ -310,3 +307,2 @@ awsLambda?: { | ||
| type CloudflareFetchHandler = CF.ExportedHandlerFetchHandler; | ||
| //#endregion | ||
| export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve }; |
+18
-18
| { | ||
| "name": "srvx", | ||
| "version": "0.11.15", | ||
| "version": "0.11.16", | ||
| "description": "Universal Server.", | ||
@@ -62,15 +62,15 @@ "homepage": "https://srvx.h3.dev", | ||
| "devDependencies": { | ||
| "@cloudflare/workers-types": "^4.20260401.1", | ||
| "@hono/node-server": "^1.19.12", | ||
| "@cloudflare/workers-types": "^4.20260521.1", | ||
| "@hono/node-server": "^2.0.3", | ||
| "@mitata/counters": "^0.0.8", | ||
| "@mjackson/node-fetch-server": "^0.7.0", | ||
| "@types/aws-lambda": "^8.10.161", | ||
| "@types/bun": "^1.3.11", | ||
| "@types/deno": "^2.5.0", | ||
| "@types/bun": "^1.3.14", | ||
| "@types/deno": "^2.7.0", | ||
| "@types/express": "^5.0.6", | ||
| "@types/node": "^25.5.0", | ||
| "@types/node": "^25.9.1", | ||
| "@types/node-forge": "^1.3.14", | ||
| "@types/serviceworker": "^0.0.194", | ||
| "@typescript/native-preview": "^7.0.0-dev.20260401.1", | ||
| "@vitest/coverage-v8": "^4.1.2", | ||
| "@types/serviceworker": "^0.0.197", | ||
| "@typescript/native-preview": "7.0.0-dev.20260521.1", | ||
| "@vitest/coverage-v8": "^4.1.7", | ||
| "@whatwg-node/server": "^0.10.18", | ||
@@ -82,3 +82,3 @@ "automd": "^0.4.3", | ||
| "express": "^5.2.1", | ||
| "fastify": "^5.8.4", | ||
| "fastify": "^5.8.5", | ||
| "get-port-please": "^3.2.0", | ||
@@ -88,10 +88,10 @@ "mdbox": "^0.1.1", | ||
| "node-forge": "^1.4.0", | ||
| "obuild": "^0.4.32", | ||
| "oxfmt": "^0.43.0", | ||
| "oxlint": "^1.58.0", | ||
| "srvx-release": "npm:srvx@^0.11.13", | ||
| "obuild": "^0.4.35", | ||
| "oxfmt": "^0.51.0", | ||
| "oxlint": "^1.66.0", | ||
| "srvx-release": "npm:srvx@^0.11.15", | ||
| "tslib": "^2.8.1", | ||
| "typescript": "^6.0.2", | ||
| "undici": "^7.24.7", | ||
| "vitest": "^4.1.2" | ||
| "typescript": "^6.0.3", | ||
| "undici": "^8.3.0", | ||
| "vitest": "^4.1.7" | ||
| }, | ||
@@ -104,3 +104,3 @@ "resolutions": { | ||
| }, | ||
| "packageManager": "pnpm@10.33.0" | ||
| "packageManager": "pnpm@11.2.2" | ||
| } |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
112082
-4.25%2474
-4.77%