@nxtedition/http 1.0.2 → 1.0.3

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.
package/lib/index.d.ts CHANGED
@@ -94,7 +94,7 @@ export declare class Http2ServerResponse extends http2.Http2ServerResponse {
94
94
  end(data: string | Uint8Array, encoding: BufferEncoding, callback?: () => void): this;
95
95
  destroy(err?: Error): this;
96
96
  }
97
- interface CreateServerOptions extends http.ServerOptions {
97
+ export interface CreateServerOptions extends http.ServerOptions {
98
98
  logger?: Logger;
99
99
  signal?: AbortSignal;
100
100
  socketTimeout?: number;
@@ -102,11 +102,11 @@ interface CreateServerOptions extends http.ServerOptions {
102
102
  headersTimeout?: number;
103
103
  requestTimeout?: number;
104
104
  }
105
- type ContextFactory = (req: IncomingMessage, res: ServerResponse) => Context;
106
- type ContextOptions = Record<string, unknown> & {
105
+ export type ContextFactory = (req: IncomingMessage, res: ServerResponse) => Context;
106
+ export type ContextOptions = Record<string, unknown> & {
107
107
  logger?: Logger;
108
108
  };
109
- export declare function createServer(ctx: ContextFactory | ContextOptions, middleware?: MiddlewareFn | MiddlewareFn[]): http.Server;
110
- export declare function createServer(options: CreateServerOptions, ctx: ContextOptions | ContextFactory, middleware?: MiddlewareFn | MiddlewareFn[]): http.Server;
111
- type MiddlewareFn = (ctx: Context, next: () => void | Promise<void>) => void | Promise<void>;
112
- export declare const compose: (...middleware: (MiddlewareFn | MiddlewareFn[])[]) => MiddlewareFn;
109
+ export declare function createServer(ctx: ContextFactory | ContextOptions, middleware?: Middleware | Middleware[]): http.Server;
110
+ export declare function createServer(options: CreateServerOptions, ctx: ContextOptions | ContextFactory, middleware?: Middleware | Middleware[]): http.Server;
111
+ export type Middleware = (ctx: Context, next: () => void | Promise<void>) => void | Promise<void>;
112
+ export declare const compose: (...middleware: (Middleware | Middleware[])[]) => Middleware;
package/lib/index.js CHANGED
@@ -932,7 +932,7 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
932
932
  }
933
933
  }
934
934
 
935
-
935
+
936
936
 
937
937
 
938
938
 
@@ -941,32 +941,32 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
941
941
 
942
942
 
943
943
 
944
-
945
-
944
+
945
+
946
946
 
947
947
  const httpServers = ((globalThis ).__nxt_lib_http_servers =
948
948
  new Array ())
949
949
 
950
950
 
951
-
951
+
952
952
 
953
953
 
954
954
 
955
955
 
956
-
956
+
957
957
 
958
958
  export function createServer(...args ) {
959
959
  let options
960
960
  let ctx
961
- let middleware
961
+ let middleware
962
962
 
963
963
  if (typeof args[0] === 'function') {
964
964
  ctx = args[0]
965
- middleware = args[1]
965
+ middleware = args[1]
966
966
  } else {
967
967
  options = args[0]
968
968
  ctx = args[1]
969
- middleware = args[2]
969
+ middleware = args[2]
970
970
  }
971
971
 
972
972
  if (middleware) {
@@ -1027,10 +1027,10 @@ export function createServer(...args ) {
1027
1027
  return server
1028
1028
  }
1029
1029
 
1030
-
1030
+
1031
1031
 
1032
1032
  const composeSlim =
1033
- (middleware ) =>
1033
+ (middleware ) =>
1034
1034
  (ctx, next) => {
1035
1035
  const dispatch = (i ) => () => {
1036
1036
  const fn = i === middleware.length ? next : middleware[i]
@@ -1039,7 +1039,7 @@ const composeSlim =
1039
1039
  return dispatch(0)()
1040
1040
  }
1041
1041
 
1042
- export const compose = (...middleware ) => {
1042
+ export const compose = (...middleware ) => {
1043
1043
  const funcs = middleware.flat()
1044
1044
 
1045
1045
  for (const fn of funcs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/http",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -32,5 +32,5 @@
32
32
  "rimraf": "^6.1.2",
33
33
  "typescript": "^5.9.3"
34
34
  },
35
- "gitHead": "37c6127808e4ed12b94810c04dc9788afaad7222"
35
+ "gitHead": "be57f23ab8b0c6d10e8a5d600e0d5f15a9e209d5"
36
36
  }