@nxtedition/http 1.0.3 → 1.0.5

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
@@ -1,9 +1,14 @@
1
1
  import http2 from 'node:http2';
2
2
  import type net from 'node:net';
3
- import type { RequestTarget } from 'request-target';
4
3
  import http from 'http';
5
4
  import type { Logger } from 'pino';
6
- export type { RequestTarget };
5
+ export interface RequestTarget {
6
+ protocol: string | null;
7
+ hostname: string | null;
8
+ port: string | null;
9
+ pathname: string;
10
+ search: string;
11
+ }
7
12
  export declare const kAbortController: unique symbol;
8
13
  export declare function genReqId(): string;
9
14
  declare const kPendingIndex: unique symbol;
@@ -53,7 +58,6 @@ export declare class ServerResponse extends http.ServerResponse {
53
58
  removeHeader(key: string): void;
54
59
  getHeaderNames(): string[];
55
60
  getHeaders(): Record<string, string | undefined>;
56
- get headersSent(): boolean;
57
61
  writeHead(statusCode: number, statusMessage?: string, headers?: http.OutgoingHttpHeaders): this;
58
62
  writeHead(statusCode: number, headers?: http.OutgoingHttpHeaders): this;
59
63
  assignSocket(socket: net.Socket): void;
@@ -84,7 +88,6 @@ export declare class Http2ServerResponse extends http2.Http2ServerResponse {
84
88
  removeHeader(key: string): void;
85
89
  getHeaderNames(): string[];
86
90
  getHeaders(): Record<string, string | undefined>;
87
- get headersSent(): boolean;
88
91
  writeHead(statusCode: number, headers?: http2.OutgoingHttpHeaders): this;
89
92
  writeHead(statusCode: number, statusMessage: string, headers?: http2.OutgoingHttpHeaders): this;
90
93
  write(chunk: string | Uint8Array, callback?: (err: Error) => void): boolean;
@@ -110,3 +113,4 @@ export declare function createServer(ctx: ContextFactory | ContextOptions, middl
110
113
  export declare function createServer(options: CreateServerOptions, ctx: ContextOptions | ContextFactory, middleware?: Middleware | Middleware[]): http.Server;
111
114
  export type Middleware = (ctx: Context, next: () => void | Promise<void>) => void | Promise<void>;
112
115
  export declare const compose: (...middleware: (Middleware | Middleware[])[]) => Middleware;
116
+ export {};
package/lib/index.js CHANGED
@@ -4,13 +4,18 @@ import { TLSSocket } from 'node:tls'
4
4
 
5
5
  import { performance } from 'perf_hooks'
6
6
  import requestTarget from 'request-target'
7
-
8
7
  import querystring from 'fast-querystring'
9
8
  import http from 'http'
10
9
  import { parsePriority, Scheduler } from '@nxtedition/scheduler'
11
10
 
12
11
 
13
-
12
+
13
+
14
+
15
+
16
+
17
+
18
+
14
19
 
15
20
  export const kAbortController = Symbol('abortController')
16
21
 
@@ -579,9 +584,13 @@ export class ServerResponse extends http.ServerResponse {
579
584
  return this.#headersObj
580
585
  }
581
586
 
582
- // @ts-expect-error override property with accessor
583
- get headersSent() {
584
- return this.#headersSent
587
+ static {
588
+ Object.defineProperty(ServerResponse.prototype, 'headersSent', {
589
+ get( ) {
590
+ return this.#headersSent
591
+ },
592
+ configurable: true,
593
+ })
585
594
  }
586
595
 
587
596
 
@@ -815,9 +824,13 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
815
824
  return this.#headersObj
816
825
  }
817
826
 
818
- // @ts-expect-error override property with accessor
819
- get headersSent() {
820
- return this.#headersSent
827
+ static {
828
+ Object.defineProperty(Http2ServerResponse.prototype, 'headersSent', {
829
+ get( ) {
830
+ return this.#headersSent
831
+ },
832
+ configurable: true,
833
+ })
821
834
  }
822
835
 
823
836
 
@@ -0,0 +1,14 @@
1
+ declare module 'request-target' {
2
+ import type http from 'node:http'
3
+
4
+ export interface RequestTarget {
5
+ protocol: string | null
6
+ hostname: string | null
7
+ port: string | null
8
+ pathname: string
9
+ search: string
10
+ }
11
+
12
+ function requestTarget(req: http.IncomingMessage): RequestTarget | null
13
+ export default requestTarget
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/http",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "scripts": {
17
- "build": "rimraf lib && tsc && amaroc ./src/index.ts && mv src/index.js lib/",
17
+ "build": "rimraf lib && tsc && amaroc ./src/index.ts && mv src/index.js lib/ && cp src/request-target.d.ts lib/",
18
18
  "prepublishOnly": "yarn build",
19
19
  "typecheck": "tsc --noEmit",
20
20
  "test": "node --test --experimental-test-coverage --test-coverage-include=src/index.ts --test-coverage-lines=65 --test-coverage-branches=80 --test-coverage-functions=60",
@@ -28,9 +28,8 @@
28
28
  "devDependencies": {
29
29
  "@types/node": "^25.2.3",
30
30
  "amaroc": "^1.0.1",
31
- "oxlint-tsgolint": "^0.12.2",
32
- "rimraf": "^6.1.2",
31
+ "oxlint-tsgolint": "^0.13.0",
32
+ "rimraf": "^6.1.3",
33
33
  "typescript": "^5.9.3"
34
- },
35
- "gitHead": "be57f23ab8b0c6d10e8a5d600e0d5f15a9e209d5"
34
+ }
36
35
  }