Sign In

srvx

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

srvx - npm Package Compare versions

Comparing version
0.12.4
to
0.12.5
+253
-20
dist/_chunks/types.d.mts
import * as NodeHttp from "node:http";
import * as NodeHttps from "node:https";
import * as NodeHttp2 from "node:http2";
import * as AWS from "aws-lambda";
import * as NodeNet from "node:net";
import * as Bun from "bun";
import * as CF from "@cloudflare/workers-types";
/**

@@ -27,5 +24,235 @@ * Controls whether `X-Forwarded-*` headers (proto, host, for, and the HTTP/2

type TrustProxyOption = boolean | "loopback" | string[];
/**
* Options forwarded to `Bun.serve()`.
*
* @docs https://bun.sh/docs/api/http
*/
interface BunServeOptions {
port?: string | number;
hostname?: string;
unix?: string;
reusePort?: boolean;
idleTimeout?: number;
maxRequestBodySize?: number;
error?: (error: any) => any;
tls?: any;
/** Any other option supported by the running Bun version. */
[key: string]: any;
}
/**
* Server instance returned by `Bun.serve()` (`Bun.Server`).
*/
interface BunHttpServer {
readonly url: URL;
readonly port?: number;
readonly hostname?: string;
readonly development?: boolean;
readonly pendingRequests?: number;
readonly pendingWebSockets?: number;
requestIP(request: Request): {
address: string;
family: "IPv4" | "IPv6";
port: number;
} | null;
timeout(request: Request, seconds: number): void;
/** Upgrade an incoming request to a WebSocket connection. */
upgrade(request: Request, options?: {
headers?: HeadersInit;
data?: any;
}): boolean;
/** Publish a message to every client subscribed to `topic`. */
publish(topic: string, data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, compress?: boolean): number;
subscriberCount(topic: string): number;
reload(options: any): void;
stop(closeActiveConnections?: boolean): Promise<void>;
ref(): void;
unref(): void;
}
/**
* Options forwarded to `Deno.serve()`.
*
* @docs https://docs.deno.com/api/deno/~/Deno.serve
*/
interface DenoServeOptions {
port?: number;
hostname?: string;
reusePort?: boolean;
signal?: AbortSignal;
key?: string;
cert?: string;
passphrase?: string;
onError?: (error: unknown) => Response | Promise<Response>;
onListen?: (localAddr: {
hostname: string;
port: number;
}) => void;
/** Any other option supported by the running Deno version. */
[key: string]: any;
}
/**
* Server instance returned by `Deno.serve()` (`Deno.HttpServer`).
*/
interface DenoHttpServer {
readonly finished: Promise<void>;
readonly addr?: {
hostname?: string;
port?: number;
transport?: string;
};
shutdown(): Promise<void>;
ref(): void;
unref(): void;
[Symbol.asyncDispose](): PromiseLike<void>;
}
/**
* Second argument Deno passes to the fetch handler (`Deno.ServeHandlerInfo`).
*/
interface DenoServeHandlerInfo {
readonly remoteAddr: {
hostname: string;
port: number;
transport?: string;
};
readonly completed?: Promise<void>;
}
/**
* Cloudflare Workers execution context (`ExecutionContext`).
*/
interface CloudflareExecutionContext {
waitUntil(promise: Promise<any>): void;
passThroughOnException(): void;
props?: any;
}
/**
* Cloudflare Workers environment bindings.
*
* Augment this interface to type your own bindings:
*
* ```ts
* declare module "srvx" {
* interface CloudflareEnv {
* MY_KV: KVNamespace;
* }
* }
* ```
*/
interface CloudflareEnv {
[key: string]: unknown;
}
/**
* AWS Lambda invocation context (`aws-lambda`'s `Context`).
*/
interface AWSLambdaContext {
callbackWaitsForEmptyEventLoop: boolean;
functionName: string;
functionVersion: string;
invokedFunctionArn: string;
memoryLimitInMB: string;
awsRequestId: string;
logGroupName: string;
logStreamName: string;
identity?: any;
clientContext?: any;
getRemainingTimeInMillis(): number;
done(error?: Error, result?: any): void;
fail(error: Error | string): void;
succeed(messageOrObject: any): void;
}
/**
* API Gateway REST API (v1) proxy event (`APIGatewayProxyEvent`).
*/
interface AWSLambdaProxyEvent {
httpMethod: string;
path: string;
resource?: string;
headers: Record<string, string | undefined>;
multiValueHeaders?: Record<string, string[] | undefined>;
queryStringParameters?: Record<string, string | undefined> | null;
multiValueQueryStringParameters?: Record<string, string[] | undefined> | null;
pathParameters?: Record<string, string | undefined> | null;
stageVariables?: Record<string, string | undefined> | null;
body: string | null;
isBase64Encoded: boolean;
requestContext: {
accountId?: string;
apiId?: string;
authorizer?: any;
domainName?: string;
httpMethod?: string;
identity?: {
sourceIp?: string;
};
path?: string;
protocol?: string;
requestId?: string;
requestTimeEpoch?: number;
resourcePath?: string;
stage?: string;
};
}
/**
* API Gateway HTTP API (v2) proxy event (`APIGatewayProxyEventV2`).
*/
interface AWSLambdaProxyEventV2 {
version: string;
routeKey?: string;
rawPath: string;
rawQueryString: string;
cookies?: string[];
headers: Record<string, string | undefined>;
queryStringParameters?: Record<string, string | undefined>;
pathParameters?: Record<string, string | undefined>;
stageVariables?: Record<string, string | undefined>;
body?: string;
isBase64Encoded: boolean;
requestContext: {
accountId?: string;
apiId?: string;
authorizer?: any;
domainName?: string;
domainPrefix?: string;
requestId?: string;
routeKey?: string;
stage?: string;
time?: string;
timeEpoch?: number;
http?: {
method: string;
path?: string;
protocol?: string;
sourceIp?: string;
userAgent?: string;
};
};
}
/**
* API Gateway REST API (v1) proxy result (`APIGatewayProxyResult`).
*/
interface AWSLambdaProxyResult {
statusCode: number;
headers?: Record<string, string | number | boolean>;
multiValueHeaders?: Record<string, Array<string | number | boolean>>;
body: string;
isBase64Encoded?: boolean;
}
/**
* API Gateway HTTP API (v2) proxy result (`APIGatewayProxyResultV2`).
*/
type AWSLambdaProxyResultV2 = string | {
statusCode?: number;
headers?: Record<string, string | number | boolean>;
body?: string;
isBase64Encoded?: boolean;
cookies?: string[];
};
/**
* Service worker `fetch` event (`FetchEvent`).
*/
interface ServiceWorkerFetchEvent {
readonly request: Request;
readonly clientId?: string;
respondWith(response: Response | Promise<Response>): void;
waitUntil(promise: Promise<any>): void;
}
type MaybePromise<T> = T | Promise<T>;
type IsAny<T> = Equal<T, any> extends true ? true : false;
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
/**

@@ -191,3 +418,3 @@ * Faster URL constructor with lazy access to pathname and search params (For Node, Deno, and Bun).

*/
bun?: Omit<Bun.Serve.Options<any>, "fetch">;
bun?: BunServeOptions;
/**

@@ -198,3 +425,3 @@ * Deno server options

*/
deno?: Deno.ServeOptions;
deno?: DenoServeOptions;
/**

@@ -241,3 +468,3 @@ * Service worker options

readonly bun?: {
server?: Bun.Server<any>;
server?: BunHttpServer;
};

@@ -248,3 +475,3 @@ /**

readonly deno?: {
server?: Deno.HttpServer;
server?: DenoHttpServer;
};

@@ -293,3 +520,3 @@ /**

deno?: {
info: Deno.ServeHandlerInfo<Deno.NetAddr>;
info: DenoServeHandlerInfo;
};

@@ -300,3 +527,3 @@ /**

bun?: {
server: Bun.Server<any>;
server: BunHttpServer;
};

@@ -307,11 +534,11 @@ /**

cloudflare?: {
context: CF.ExecutionContext;
env: IsAny<typeof import("cloudflare:workers")> extends true ? Record<string, unknown> : typeof import("cloudflare:workers").env;
context: CloudflareExecutionContext;
env: CloudflareEnv;
};
awsLambda?: {
context: AWS.Context;
event: AWS.APIGatewayProxyEvent | AWS.APIGatewayProxyEventV2;
context: AWSLambdaContext;
event: AWSLambdaProxyEvent | AWSLambdaProxyEventV2;
};
serviceWorker?: {
event: FetchEvent;
event: ServiceWorkerFetchEvent;
};

@@ -364,4 +591,4 @@ netlify?: {

type ErrorHandler = (error: unknown) => Response | Promise<Response>;
type BunFetchHandler = (request: Request, server?: Bun.Server<any>) => Response | Promise<Response>;
type DenoFetchHandler = (request: Request, info?: Deno.ServeHandlerInfo<Deno.NetAddr>) => Response | Promise<Response>;
type BunFetchHandler = (request: Request, server?: BunHttpServer) => Response | Promise<Response>;
type DenoFetchHandler = (request: Request, info?: DenoServeHandlerInfo) => Response | Promise<Response>;
type NodeServerRequest = NodeHttp.IncomingMessage | NodeHttp2.Http2ServerRequest;

@@ -375,3 +602,9 @@ type NodeServerResponse = NodeHttp.ServerResponse | NodeHttp2.Http2ServerResponse;

type NodeHTTPMiddleware = NodeHTTP1Middleware | NodeHTTP2Middleware;
type CloudflareFetchHandler = CF.ExportedHandlerFetchHandler;
export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, TrustProxyOption, serve };
type CloudflareFetchHandler = (request: Request, env: CloudflareEnv, context: CloudflareExecutionContext) => Response | Promise<Response>;
/**
* Body accepted by the runtime `Response` constructor (`BodyInit`).
*
* Derived from the ambient `Response` so that it does not require `lib: ["dom"]`.
*/
type ResponseBody = NonNullable<ConstructorParameters<typeof globalThis.Response>[0]>;
export { AWSLambdaContext, AWSLambdaProxyEvent, AWSLambdaProxyEventV2, AWSLambdaProxyResult, AWSLambdaProxyResultV2, BunFetchHandler, BunHttpServer, BunServeOptions, CloudflareEnv, CloudflareExecutionContext, CloudflareFetchHandler, DenoFetchHandler, DenoHttpServer, DenoServeHandlerInfo, DenoServeOptions, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, ResponseBody, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, ServiceWorkerFetchEvent, TrustProxyOption, serve };
+6
-7

@@ -1,3 +0,2 @@

import { FetchHandler, ServerOptions, TrustProxyOption } from "../_chunks/types.mjs";
import * as AWS from "aws-lambda";
import { AWSLambdaContext, AWSLambdaProxyEvent, AWSLambdaProxyEventV2, AWSLambdaProxyResult, AWSLambdaProxyResultV2, FetchHandler, ServerOptions, TrustProxyOption } from "../_chunks/types.mjs";
type AWSLambdaResponseStream = NodeJS.WritableStream & {

@@ -7,9 +6,9 @@ setContentType(contentType: string): void;

type MaybePromise<T> = T | Promise<T>;
type AwsLambdaEvent = AWS.APIGatewayProxyEvent | AWS.APIGatewayProxyEventV2;
type AWSLambdaHandler = (event: AwsLambdaEvent, context: AWS.Context) => MaybePromise<AWS.APIGatewayProxyResult | AWS.APIGatewayProxyResultV2>;
type AWSLambdaStreamingHandler = (event: AwsLambdaEvent, responseStream: AWSLambdaResponseStream, context: AWS.Context) => MaybePromise<void>;
type AwsLambdaEvent = AWSLambdaProxyEvent | AWSLambdaProxyEventV2;
type AWSLambdaHandler = (event: AwsLambdaEvent, context: AWSLambdaContext) => MaybePromise<AWSLambdaProxyResult | AWSLambdaProxyResultV2>;
type AWSLambdaStreamingHandler = (event: AwsLambdaEvent, responseStream: AWSLambdaResponseStream, context: AWSLambdaContext) => MaybePromise<void>;
declare function toLambdaHandler(options: ServerOptions): AWSLambdaHandler;
declare function handleLambdaEvent(fetchHandler: FetchHandler, event: AwsLambdaEvent, context: AWS.Context, trustProxy?: TrustProxyOption): Promise<AWS.APIGatewayProxyResult | AWS.APIGatewayProxyResultV2>;
declare function handleLambdaEventWithStream(fetchHandler: FetchHandler, event: AwsLambdaEvent, responseStream: AWSLambdaResponseStream, context: AWS.Context, trustProxy?: TrustProxyOption): Promise<void>;
declare function handleLambdaEvent(fetchHandler: FetchHandler, event: AwsLambdaEvent, context: AWSLambdaContext, trustProxy?: TrustProxyOption): Promise<AWSLambdaProxyResult | AWSLambdaProxyResultV2>;
declare function handleLambdaEventWithStream(fetchHandler: FetchHandler, event: AwsLambdaEvent, responseStream: AWSLambdaResponseStream, context: AWSLambdaContext, trustProxy?: TrustProxyOption): Promise<void>;
declare function invokeLambdaHandler(handler: AWSLambdaHandler, request: Request): Promise<Response>;
export { AWSLambdaHandler, type AWSLambdaResponseStream, AWSLambdaStreamingHandler, AwsLambdaEvent, handleLambdaEvent, handleLambdaEventWithStream, invokeLambdaHandler, toLambdaHandler };

@@ -1,4 +0,3 @@

import { BunFetchHandler, Server, ServerOptions } from "../_chunks/types.mjs";
import { BunFetchHandler, BunServeOptions, Server, ServerOptions } from "../_chunks/types.mjs";
import { FastURL } from "../_chunks/_url.mjs";
import * as bun from "bun";
declare const FastResponse: typeof globalThis.Response;

@@ -11,3 +10,3 @@ declare function serve(options: ServerOptions): BunServer;

readonly bun: Server["bun"];
readonly serveOptions: bun.Serve.Options<any> | undefined;
readonly serveOptions: BunServeOptions | undefined;
readonly fetch: BunFetchHandler;

@@ -14,0 +13,0 @@ readonly waitUntil?: Server["waitUntil"];

@@ -1,6 +0,5 @@

import { Server, ServerOptions } from "../_chunks/types.mjs";
import * as CF from "@cloudflare/workers-types";
import { CloudflareFetchHandler, Server, ServerOptions } from "../_chunks/types.mjs";
declare const FastURL: typeof globalThis.URL;
declare const FastResponse: typeof globalThis.Response;
declare function serve(options: ServerOptions): Server<CF.ExportedHandlerFetchHandler>;
declare function serve(options: ServerOptions): Server<CloudflareFetchHandler>;
export { FastResponse, FastURL, serve };

@@ -1,2 +0,2 @@

import { DenoFetchHandler, Server, ServerOptions } from "../_chunks/types.mjs";
import { DenoFetchHandler, DenoServeOptions, Server, ServerOptions } from "../_chunks/types.mjs";
import { FastURL } from "../_chunks/_url.mjs";

@@ -10,3 +10,3 @@ declare const FastResponse: typeof globalThis.Response;

readonly deno: Server["deno"];
readonly serveOptions: Deno.ServeTcpOptions | (Deno.ServeTcpOptions & Deno.TlsCertifiedKeyPem) | undefined;
readonly serveOptions: DenoServeOptions | undefined;
readonly fetch: DenoFetchHandler;

@@ -13,0 +13,0 @@ readonly waitUntil?: Server["waitUntil"];

@@ -56,3 +56,3 @@ import { FastURL } from "../_chunks/_url.mjs";

get() {
return (info?.remoteAddr)?.hostname;
return info?.remoteAddr?.hostname;
}

@@ -59,0 +59,0 @@ }

@@ -1,2 +0,2 @@

import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest, TrustProxyOption } from "../_chunks/types.mjs";
import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, ResponseBody, Server, ServerOptions, ServerRequest, TrustProxyOption } from "../_chunks/types.mjs";
import { FastURL } from "../_chunks/_url.mjs";

@@ -43,3 +43,3 @@ import { Readable } from "node:stream";

declare const NodeResponse: {
new (body?: BodyInit | null, init?: ResponseInit): globalThis.Response & {
new (body?: ResponseBody | null, init?: ResponseInit): globalThis.Response & {
_toNodeResponse: () => PreparedNodeResponse;

@@ -46,0 +46,0 @@ };

@@ -1,6 +0,6 @@

import { Server, ServerOptions, ServerRequest } from "../_chunks/types.mjs";
import { Server, ServerOptions, ServerRequest, ServiceWorkerFetchEvent } from "../_chunks/types.mjs";
declare const FastURL: typeof globalThis.URL;
declare const FastResponse: typeof globalThis.Response;
type ServiceWorkerHandler = (request: ServerRequest, event: FetchEvent) => Response | Promise<Response>;
type ServiceWorkerHandler = (request: ServerRequest, event: ServiceWorkerFetchEvent) => Response | Promise<Response>;
declare function serve(options: ServerOptions): Server<ServiceWorkerHandler>;
export { FastResponse, FastURL, ServiceWorkerHandler, serve };

@@ -208,3 +208,3 @@ import { bold, cyan, gray, green, magenta, red, url, yellow } from "./_chunks/_utils.mjs";

name: "srvx",
version: "0.12.3",
version: "0.12.4",
description: "Universal Server."

@@ -211,0 +211,0 @@ };

@@ -1,2 +0,2 @@

import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, TrustProxyOption, serve } from "./_chunks/types.mjs";
export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, type TrustProxyOption, serve };
import { AWSLambdaContext, AWSLambdaProxyEvent, AWSLambdaProxyEventV2, AWSLambdaProxyResult, AWSLambdaProxyResultV2, BunFetchHandler, BunHttpServer, BunServeOptions, CloudflareEnv, CloudflareExecutionContext, CloudflareFetchHandler, DenoFetchHandler, DenoHttpServer, DenoServeHandlerInfo, DenoServeOptions, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, ResponseBody, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, ServiceWorkerFetchEvent, TrustProxyOption, serve } from "./_chunks/types.mjs";
export { type AWSLambdaContext, type AWSLambdaProxyEvent, type AWSLambdaProxyEventV2, type AWSLambdaProxyResult, type AWSLambdaProxyResultV2, BunFetchHandler, type BunHttpServer, type BunServeOptions, type CloudflareEnv, type CloudflareExecutionContext, CloudflareFetchHandler, DenoFetchHandler, type DenoHttpServer, type DenoServeHandlerInfo, type DenoServeOptions, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTP1Middleware, NodeHTTP2Middleware, NodeHTTPMiddleware, NodeHttp1Handler, NodeHttp2Handler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, ResponseBody, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, type ServiceWorkerFetchEvent, type TrustProxyOption, serve };
{
"name": "srvx",
"version": "0.12.4",
"version": "0.12.5",
"description": "Universal Server.",

@@ -5,0 +5,0 @@ "homepage": "https://srvx.h3.dev",