Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/server

Package Overview
Dependencies
Maintainers
1
Versions
736
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/server - npm Package Compare versions

Comparing version 0.4.10-alpha-20220926221307-730c2a6 to 0.4.10-alpha-20220926221825-952acbf

21

index.d.ts

@@ -5,3 +5,3 @@ /// <reference types="node" />

import { NodeRequest } from './utils';
export interface ServerAdapterBaseObject<TServerContext> {
export interface ServerAdapterBaseObject<TServerContext, THandleRequest extends ServerAdapterRequestHandler<TServerContext> = ServerAdapterRequestHandler<TServerContext>> {
/**

@@ -11,9 +11,9 @@ * An async function that takes `Request` and the server context and returns a `Response`.

*/
handle: ServerAdapterRequestHandler<TServerContext>;
handle: THandleRequest;
}
export interface ServerAdapterObject<TServerContext> extends EventListenerObject {
export interface ServerAdapterObject<TServerContext, TBaseObject extends ServerAdapterBaseObject<TServerContext, ServerAdapterRequestHandler<TServerContext>>> extends EventListenerObject {
/**
* A basic request listener that takes a `Request` with the server context and returns a `Response`.
*/
handleRequest: ServerAdapterRequestHandler<TServerContext>;
handleRequest: TBaseObject['handle'];
/**

@@ -40,5 +40,2 @@ * WHATWG Fetch spec compliant `fetch` function that can be used for testing purposes.

requestListener: RequestListener;
/**
* Flexible and generic request handler for all environments.
*/
handle(req: NodeRequest, res: ServerResponse, ...ctx: Partial<TServerContext>[]): Promise<void>;

@@ -51,11 +48,11 @@ handle(request: Request, ...ctx: Partial<TServerContext>[]): Promise<Response> | Response;

}
export declare type ServerAdapter<TServerContext> = ServerAdapterObject<TServerContext>['handle'] & ServerAdapterObject<TServerContext>['requestListener'] & ServerAdapterObject<TServerContext>;
export declare type ServerAdapter<TServerContext, TBaseObject extends ServerAdapterBaseObject<TServerContext>> = TBaseObject & ServerAdapterObject<TServerContext, TBaseObject>['handle'] & ServerAdapterObject<TServerContext, TBaseObject>;
export declare type ServerAdapterRequestHandler<TServerContext> = (request: Request, ctx: TServerContext) => Promise<Response> | Response;
export interface NodeServerAdapterContext {
export declare type DefaultServerAdapterContext = {
req: NodeRequest;
res: ServerResponse;
waitUntil(promise: Promise<unknown>): void;
}
declare function createServerAdapter<TServerContext>(serverAdapterRequestHandler: ServerAdapterRequestHandler<TServerContext>, RequestCtor?: typeof Request): ServerAdapter<TServerContext>;
declare function createServerAdapter<TServerContext>(serverAdapterBaseObject: ServerAdapterBaseObject<TServerContext>, RequestCtor?: typeof Request): ServerAdapter<TServerContext>;
};
declare function createServerAdapter<TServerContext = DefaultServerAdapterContext, THandleRequest extends ServerAdapterRequestHandler<TServerContext> = ServerAdapterRequestHandler<TServerContext>>(serverAdapterRequestHandler: THandleRequest, RequestCtor?: typeof Request): ServerAdapter<TServerContext, ServerAdapterBaseObject<TServerContext, THandleRequest>>;
declare function createServerAdapter<TServerContext, TBaseObject extends ServerAdapterBaseObject<TServerContext>>(serverAdapterBaseObject: TBaseObject, RequestCtor?: typeof Request): ServerAdapter<TServerContext, TBaseObject>;
export { createServerAdapter };

@@ -233,3 +233,3 @@ 'use strict';

const waitUntilPromises = [];
const nodeServerContext = {
const defaultServerContext = {
req: nodeRequest,

@@ -241,3 +241,3 @@ res: serverResponse,

};
const response = await handleNodeRequest(nodeRequest, nodeServerContext, ...ctx);
const response = await handleNodeRequest(nodeRequest, defaultServerContext, ...ctx);
if (response) {

@@ -244,0 +244,0 @@ await sendNodeResponse(response, serverResponse);

{
"name": "@whatwg-node/server",
"version": "0.4.10-alpha-20220926221307-730c2a6",
"version": "0.4.10-alpha-20220926221825-952acbf",
"description": "Fetch API compliant HTTP Server adapter",

@@ -10,3 +10,3 @@ "sideEffects": false,

"dependencies": {
"@whatwg-node/fetch": "0.4.6-alpha-20220926221307-730c2a6",
"@whatwg-node/fetch": "0.4.6-alpha-20220926221825-952acbf",
"tslib": "^2.3.1"

@@ -13,0 +13,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc