@jaypie/express 1.2.4-rc0 → 1.2.4-rc10
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/dist/cjs/adapter/LambdaRequest.d.ts +5 -5
- package/dist/cjs/adapter/LambdaResponseBuffered.d.ts +31 -9
- package/dist/cjs/adapter/LambdaResponseStreaming.d.ts +28 -6
- package/dist/cjs/adapter/index.d.ts +3 -3
- package/dist/cjs/adapter/types.d.ts +34 -2
- package/dist/cjs/index.cjs +497 -40
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/esm/adapter/LambdaRequest.d.ts +5 -5
- package/dist/esm/adapter/LambdaResponseBuffered.d.ts +31 -9
- package/dist/esm/adapter/LambdaResponseStreaming.d.ts +28 -6
- package/dist/esm/adapter/index.d.ts +3 -3
- package/dist/esm/adapter/types.d.ts +34 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +497 -40
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createLambdaHandler, createLambdaStreamHandler, getCurrentInvoke, LambdaRequest, LambdaResponseBuffered, LambdaResponseStreaming, } from "./adapter/index.js";
|
|
2
|
-
export type { CreateLambdaHandlerOptions, FunctionUrlEvent, LambdaHandler, LambdaResponse, LambdaStreamHandler, } from "./adapter/index.js";
|
|
2
|
+
export type { ApiGatewayV1Event, CreateLambdaHandlerOptions, FunctionUrlEvent, LambdaContext, LambdaEvent, LambdaHandler, LambdaResponse, LambdaStreamHandler, ResponseStream, } from "./adapter/index.js";
|
|
3
3
|
export { EXPRESS } from "./constants.js";
|
|
4
4
|
export { default as cors } from "./cors.helper.js";
|
|
5
5
|
export type { CorsConfig } from "./cors.helper.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { IncomingHttpHeaders } from "node:http";
|
|
2
2
|
import { Readable } from "node:stream";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LambdaContext, LambdaEvent } from "./types.js";
|
|
4
4
|
interface LambdaRequestOptions {
|
|
5
5
|
body?: Buffer | null;
|
|
6
6
|
headers: Record<string, string>;
|
|
7
7
|
lambdaContext: LambdaContext;
|
|
8
|
-
lambdaEvent:
|
|
8
|
+
lambdaEvent: LambdaEvent;
|
|
9
9
|
method: string;
|
|
10
10
|
protocol: string;
|
|
11
11
|
remoteAddress: string;
|
|
@@ -37,7 +37,7 @@ export declare class LambdaRequest extends Readable {
|
|
|
37
37
|
params: Record<string, string>;
|
|
38
38
|
query: Record<string, unknown>;
|
|
39
39
|
readonly _lambdaContext: LambdaContext;
|
|
40
|
-
readonly _lambdaEvent:
|
|
40
|
+
readonly _lambdaEvent: LambdaEvent;
|
|
41
41
|
private bodyBuffer;
|
|
42
42
|
private bodyPushed;
|
|
43
43
|
constructor(options: LambdaRequestOptions);
|
|
@@ -47,7 +47,7 @@ export declare class LambdaRequest extends Readable {
|
|
|
47
47
|
private normalizeHeaders;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Create a LambdaRequest from a Function URL
|
|
50
|
+
* Create a LambdaRequest from a Lambda event (Function URL, HTTP API v2, or REST API v1).
|
|
51
51
|
*/
|
|
52
|
-
export declare function createLambdaRequest(event:
|
|
52
|
+
export declare function createLambdaRequest(event: LambdaEvent, context: LambdaContext): LambdaRequest;
|
|
53
53
|
export default LambdaRequest;
|
|
@@ -9,17 +9,17 @@ export declare class LambdaResponseBuffered extends Writable {
|
|
|
9
9
|
statusCode: number;
|
|
10
10
|
statusMessage: string;
|
|
11
11
|
readonly socket: {
|
|
12
|
-
cork: () => void;
|
|
13
|
-
destroy: () => void;
|
|
14
12
|
remoteAddress: string;
|
|
15
|
-
uncork: () => void;
|
|
16
|
-
writable: boolean;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
_chunks: Buffer[];
|
|
15
|
+
_headers: Map<string, string | string[]>;
|
|
16
|
+
_headersSent: boolean;
|
|
17
|
+
_resolve: ((result: LambdaResponse) => void) | null;
|
|
22
18
|
constructor();
|
|
19
|
+
_internalGetHeader(name: string): string | undefined;
|
|
20
|
+
_internalSetHeader(name: string, value: string): void;
|
|
21
|
+
_internalHasHeader(name: string): boolean;
|
|
22
|
+
_internalRemoveHeader(name: string): void;
|
|
23
23
|
getResult(): Promise<LambdaResponse>;
|
|
24
24
|
setHeader(name: string, value: number | string | string[]): this;
|
|
25
25
|
getHeader(name: string): number | string | string[] | undefined;
|
|
@@ -27,15 +27,37 @@ export declare class LambdaResponseBuffered extends Writable {
|
|
|
27
27
|
getHeaders(): OutgoingHttpHeaders;
|
|
28
28
|
hasHeader(name: string): boolean;
|
|
29
29
|
getHeaderNames(): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Proxy for direct header access (e.g., res.headers['content-type']).
|
|
32
|
+
* Required for compatibility with middleware like helmet that access headers directly.
|
|
33
|
+
*/
|
|
34
|
+
get headers(): Record<string, string | string[] | undefined>;
|
|
30
35
|
writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
|
|
31
36
|
get headersSent(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Express-style alias for getHeader().
|
|
39
|
+
* Used by middleware like decorateResponse that use res.get().
|
|
40
|
+
* Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
|
|
41
|
+
*/
|
|
42
|
+
get(name: string): number | string | string[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Express-style alias for setHeader().
|
|
45
|
+
* Used by middleware like decorateResponse that use res.set().
|
|
46
|
+
* Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
|
|
47
|
+
*/
|
|
48
|
+
set(name: string, value: number | string | string[]): this;
|
|
32
49
|
status(code: number): this;
|
|
33
50
|
json(data: unknown): this;
|
|
34
51
|
send(body?: Buffer | object | string): this;
|
|
52
|
+
/**
|
|
53
|
+
* Add a field to the Vary response header.
|
|
54
|
+
* Used by CORS middleware to indicate response varies by Origin.
|
|
55
|
+
*/
|
|
56
|
+
vary(field: string): this;
|
|
35
57
|
_write(chunk: Buffer | string, encoding: BufferEncoding, // eslint-disable-line no-undef
|
|
36
58
|
callback: (error?: Error | null) => void): void;
|
|
37
59
|
_final(callback: (error?: Error | null) => void): void;
|
|
38
|
-
|
|
60
|
+
buildResult(): LambdaResponse;
|
|
39
61
|
private isBinaryContentType;
|
|
40
62
|
}
|
|
41
63
|
export default LambdaResponseBuffered;
|
|
@@ -9,30 +9,52 @@ export declare class LambdaResponseStreaming extends Writable {
|
|
|
9
9
|
statusCode: number;
|
|
10
10
|
statusMessage: string;
|
|
11
11
|
readonly socket: {
|
|
12
|
-
cork: () => void;
|
|
13
|
-
destroy: () => void;
|
|
14
12
|
remoteAddress: string;
|
|
15
|
-
uncork: () => void;
|
|
16
|
-
writable: boolean;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
_headers: Map<string, string | string[]>;
|
|
15
|
+
_headersSent: boolean;
|
|
20
16
|
private _pendingWrites;
|
|
21
17
|
private _responseStream;
|
|
22
18
|
private _wrappedStream;
|
|
23
19
|
constructor(responseStream: ResponseStream);
|
|
20
|
+
_internalGetHeader(name: string): string | undefined;
|
|
21
|
+
_internalSetHeader(name: string, value: string): void;
|
|
22
|
+
_internalHasHeader(name: string): boolean;
|
|
23
|
+
_internalRemoveHeader(name: string): void;
|
|
24
24
|
setHeader(name: string, value: number | string | string[]): this;
|
|
25
25
|
getHeader(name: string): number | string | string[] | undefined;
|
|
26
26
|
removeHeader(name: string): void;
|
|
27
27
|
getHeaders(): OutgoingHttpHeaders;
|
|
28
28
|
hasHeader(name: string): boolean;
|
|
29
29
|
getHeaderNames(): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Proxy for direct header access (e.g., res.headers['content-type']).
|
|
32
|
+
* Required for compatibility with middleware like helmet that access headers directly.
|
|
33
|
+
*/
|
|
34
|
+
get headers(): Record<string, string | string[] | undefined>;
|
|
30
35
|
writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
|
|
31
36
|
get headersSent(): boolean;
|
|
32
37
|
flushHeaders(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Express-style alias for getHeader().
|
|
40
|
+
* Used by middleware like decorateResponse that use res.get().
|
|
41
|
+
* Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
|
|
42
|
+
*/
|
|
43
|
+
get(name: string): number | string | string[] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Express-style alias for setHeader().
|
|
46
|
+
* Used by middleware like decorateResponse that use res.set().
|
|
47
|
+
* Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
|
|
48
|
+
*/
|
|
49
|
+
set(name: string, value: number | string | string[]): this;
|
|
33
50
|
status(code: number): this;
|
|
34
51
|
json(data: unknown): this;
|
|
35
52
|
send(body?: Buffer | object | string): this;
|
|
53
|
+
/**
|
|
54
|
+
* Add a field to the Vary response header.
|
|
55
|
+
* Used by CORS middleware to indicate response varies by Origin.
|
|
56
|
+
*/
|
|
57
|
+
vary(field: string): this;
|
|
36
58
|
_write(chunk: Buffer | string, encoding: BufferEncoding, // eslint-disable-line no-undef
|
|
37
59
|
callback: (error?: Error | null) => void): void;
|
|
38
60
|
_final(callback: (error?: Error | null) => void): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Application } from "express";
|
|
2
|
-
import type { CreateLambdaHandlerOptions,
|
|
2
|
+
import type { CreateLambdaHandlerOptions, LambdaContext, LambdaEvent, LambdaHandler, LambdaStreamHandler } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get the current Lambda invoke context.
|
|
5
5
|
* Used by getCurrentInvokeUuid adapter to get the request ID.
|
|
6
6
|
*/
|
|
7
7
|
export declare function getCurrentInvoke(): {
|
|
8
8
|
context: LambdaContext;
|
|
9
|
-
event:
|
|
9
|
+
event: LambdaEvent;
|
|
10
10
|
} | null;
|
|
11
11
|
/**
|
|
12
12
|
* Create a Lambda handler that buffers the Express response.
|
|
@@ -47,4 +47,4 @@ export declare function createLambdaStreamHandler(app: Application, _options?: C
|
|
|
47
47
|
export { LambdaRequest, createLambdaRequest } from "./LambdaRequest.js";
|
|
48
48
|
export { LambdaResponseBuffered } from "./LambdaResponseBuffered.js";
|
|
49
49
|
export { LambdaResponseStreaming } from "./LambdaResponseStreaming.js";
|
|
50
|
-
export type { AwsLambdaGlobal, CreateLambdaHandlerOptions, FunctionUrlEvent, HttpResponseStreamMetadata, LambdaContext, LambdaHandler, LambdaHandlerFactory, LambdaResponse, LambdaStreamHandler, LambdaStreamHandlerFactory, ResponseStream, } from "./types.js";
|
|
50
|
+
export type { ApiGatewayV1Event, AwsLambdaGlobal, CreateLambdaHandlerOptions, FunctionUrlEvent, HttpResponseStreamMetadata, LambdaContext, LambdaEvent, LambdaHandler, LambdaHandlerFactory, LambdaResponse, LambdaStreamHandler, LambdaStreamHandlerFactory, ResponseStream, } from "./types.js";
|
|
@@ -10,6 +10,37 @@ export interface LambdaContext {
|
|
|
10
10
|
memoryLimitInMB?: string;
|
|
11
11
|
[key: string]: unknown;
|
|
12
12
|
}
|
|
13
|
+
export interface ApiGatewayV1Event {
|
|
14
|
+
body?: string | null;
|
|
15
|
+
headers: Record<string, string>;
|
|
16
|
+
httpMethod: string;
|
|
17
|
+
isBase64Encoded: boolean;
|
|
18
|
+
multiValueHeaders?: Record<string, string[]>;
|
|
19
|
+
multiValueQueryStringParameters?: Record<string, string[]> | null;
|
|
20
|
+
path: string;
|
|
21
|
+
pathParameters?: Record<string, string> | null;
|
|
22
|
+
queryStringParameters?: Record<string, string> | null;
|
|
23
|
+
requestContext: {
|
|
24
|
+
accountId: string;
|
|
25
|
+
apiId: string;
|
|
26
|
+
domainName?: string;
|
|
27
|
+
httpMethod: string;
|
|
28
|
+
identity: {
|
|
29
|
+
sourceIp: string;
|
|
30
|
+
userAgent?: string;
|
|
31
|
+
};
|
|
32
|
+
path: string;
|
|
33
|
+
protocol: string;
|
|
34
|
+
requestId: string;
|
|
35
|
+
requestTime?: string;
|
|
36
|
+
requestTimeEpoch?: number;
|
|
37
|
+
resourceId?: string;
|
|
38
|
+
resourcePath?: string;
|
|
39
|
+
stage: string;
|
|
40
|
+
};
|
|
41
|
+
resource?: string;
|
|
42
|
+
stageVariables?: Record<string, string> | null;
|
|
43
|
+
}
|
|
13
44
|
export interface FunctionUrlEvent {
|
|
14
45
|
body?: string;
|
|
15
46
|
cookies?: string[];
|
|
@@ -38,6 +69,7 @@ export interface FunctionUrlEvent {
|
|
|
38
69
|
routeKey: string;
|
|
39
70
|
version: "2.0";
|
|
40
71
|
}
|
|
72
|
+
export type LambdaEvent = ApiGatewayV1Event | FunctionUrlEvent;
|
|
41
73
|
export interface LambdaResponse {
|
|
42
74
|
body: string;
|
|
43
75
|
cookies?: string[];
|
|
@@ -63,8 +95,8 @@ export interface AwsLambdaGlobal {
|
|
|
63
95
|
};
|
|
64
96
|
streamifyResponse<TEvent = unknown>(handler: (event: TEvent, responseStream: ResponseStream, context: LambdaContext) => Promise<void>): (event: TEvent, context: LambdaContext) => Promise<void>;
|
|
65
97
|
}
|
|
66
|
-
export type LambdaHandler = (event:
|
|
67
|
-
export type LambdaStreamHandler = (event:
|
|
98
|
+
export type LambdaHandler = (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResponse>;
|
|
99
|
+
export type LambdaStreamHandler = (event: LambdaEvent, context: LambdaContext) => Promise<void>;
|
|
68
100
|
export type CreateLambdaHandlerOptions = {
|
|
69
101
|
/**
|
|
70
102
|
* Optional name for logging and debugging
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createLambdaHandler, createLambdaStreamHandler, getCurrentInvoke, LambdaRequest, LambdaResponseBuffered, LambdaResponseStreaming, } from "./adapter/index.js";
|
|
2
|
-
export type { CreateLambdaHandlerOptions, FunctionUrlEvent, LambdaHandler, LambdaResponse, LambdaStreamHandler, } from "./adapter/index.js";
|
|
2
|
+
export type { ApiGatewayV1Event, CreateLambdaHandlerOptions, FunctionUrlEvent, LambdaContext, LambdaEvent, LambdaHandler, LambdaResponse, LambdaStreamHandler, ResponseStream, } from "./adapter/index.js";
|
|
3
3
|
export { EXPRESS } from "./constants.js";
|
|
4
4
|
export { default as cors } from "./cors.helper.js";
|
|
5
5
|
export type { CorsConfig } from "./cors.helper.js";
|