dx-server 0.0.5 → 0.0.6
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/cjs/body.d.ts +6 -0
- package/cjs/context.d.ts +3 -0
- package/cjs/context.js +6 -1
- package/cjs/express.d.ts +26 -0
- package/esm/body.d.ts +6 -0
- package/esm/context.d.ts +3 -0
- package/esm/context.js +6 -1
- package/esm/express.d.ts +26 -0
- package/package.json +1 -1
package/cjs/body.d.ts
CHANGED
|
@@ -5,26 +5,32 @@ export declare const bufferBodyContext: {
|
|
|
5
5
|
chain(params_0?: {
|
|
6
6
|
limit?: number | undefined;
|
|
7
7
|
} | undefined): <V>(next: () => V) => Promise<any>;
|
|
8
|
+
with(value: Buffer | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
8
9
|
};
|
|
9
10
|
export declare const jsonBodyContext: {
|
|
10
11
|
readonly value: any;
|
|
11
12
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
13
|
+
with(value: any): <V_1>(next: () => V_1) => Promise<any>;
|
|
12
14
|
};
|
|
13
15
|
export declare const rawBodyContext: {
|
|
14
16
|
readonly value: Buffer | undefined;
|
|
15
17
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
18
|
+
with(value: Buffer | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
16
19
|
};
|
|
17
20
|
export declare const textBodyContext: {
|
|
18
21
|
readonly value: string | undefined;
|
|
19
22
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
23
|
+
with(value: string | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
20
24
|
};
|
|
21
25
|
export declare const urlencodedBodyContext: {
|
|
22
26
|
readonly value: import("qs").ParsedQs | undefined;
|
|
23
27
|
chain(params_0?: {
|
|
24
28
|
simplify?: boolean | undefined;
|
|
25
29
|
} | undefined): <V>(next: () => V) => Promise<any>;
|
|
30
|
+
with(value: import("qs").ParsedQs | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
26
31
|
};
|
|
27
32
|
export declare const queryContext: {
|
|
28
33
|
readonly value: import("qs").ParsedQs;
|
|
29
34
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
35
|
+
with(value: import("qs").ParsedQs): <V_1>(next: () => V_1) => Promise<any>;
|
|
30
36
|
};
|
package/cjs/context.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ import { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
4
4
|
export declare const makeContext: <T, Params extends any[] = unknown[]>(maker: (...params: Params) => Promisable<T>, end?: (result: any, value: T) => any) => {
|
|
5
5
|
readonly value: T;
|
|
6
6
|
chain(...params: Params): <V>(next: () => V) => Promise<any>;
|
|
7
|
+
with(value: T): <V_1>(next: () => V_1) => Promise<any>;
|
|
7
8
|
};
|
|
8
9
|
export declare const requestContext: {
|
|
9
10
|
readonly value: IncomingMessage;
|
|
10
11
|
chain(params_0: IncomingMessage): <V>(next: () => V) => Promise<any>;
|
|
12
|
+
with(value: IncomingMessage): <V_1>(next: () => V_1) => Promise<any>;
|
|
11
13
|
};
|
|
12
14
|
export declare const responseContext: {
|
|
13
15
|
readonly value: ServerResponse<IncomingMessage>;
|
|
14
16
|
chain(params_0: ServerResponse<IncomingMessage>): <V>(next: () => V) => Promise<any>;
|
|
17
|
+
with(value: ServerResponse<IncomingMessage>): <V_1>(next: () => V_1) => Promise<any>;
|
|
15
18
|
};
|
package/cjs/context.js
CHANGED
|
@@ -15,6 +15,11 @@ const makeContext = (maker, end = jmisc_1.identity) => {
|
|
|
15
15
|
return end(await asyncLocalStorage.run(value, next), value);
|
|
16
16
|
};
|
|
17
17
|
},
|
|
18
|
+
with(value) {
|
|
19
|
+
return async (next) => {
|
|
20
|
+
return end(await asyncLocalStorage.run(value, next), value);
|
|
21
|
+
};
|
|
22
|
+
},
|
|
18
23
|
};
|
|
19
24
|
};
|
|
20
25
|
exports.makeContext = makeContext;
|
|
@@ -24,4 +29,4 @@ exports.makeContext = makeContext;
|
|
|
24
29
|
// rawHeaders: list of header name and value in a flat array. Case is preserved.
|
|
25
30
|
exports.requestContext = (0, exports.makeContext)(jmisc_1.identity);
|
|
26
31
|
exports.responseContext = (0, exports.makeContext)(jmisc_1.identity);
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHVEQUFrRDtBQUdsRCxpQ0FBOEI7QUFFdkIsTUFBTSxXQUFXLEdBQUcsQ0FDMUIsS0FBMkMsRUFDM0MsTUFBc0MsZ0JBQVEsRUFDN0MsRUFBRTtJQUNILE1BQU0saUJBQWlCLEdBQUcsSUFBSSxvQ0FBaUIsRUFBSyxDQUFBO0lBQ3BELE9BQU87UUFDTixJQUFJLEtBQUs7WUFDUixPQUFPLGlCQUFpQixDQUFDLFFBQVEsRUFBRyxDQUFBO1FBQ3JDLENBQUM7UUFDRCxLQUFLLENBQUMsR0FBRyxNQUFjO1lBQ3RCLE9BQU8sS0FBSyxFQUFLLElBQWEsRUFBRSxFQUFFO2dCQUNqQyxNQUFNLEtBQUssR0FBRyxNQUFNLEtBQUssQ0FBQyxHQUFHLE1BQU0sQ0FBQyxDQUFBO2dCQUNwQyxPQUFPLEdBQUcsQ0FBQyxNQUFNLGlCQUFpQixDQUFDLEdBQUcsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLEVBQUUsS0FBSyxDQUFDLENBQUE7WUFDNUQsQ0FBQyxDQUFBO1FBQ0YsQ0FBQztRQUNELElBQUksQ0FBQyxLQUFRO1lBQ1osT0FBTyxLQUFLLEVBQUssSUFBYSxFQUFFLEVBQUU7Z0JBQ2pDLE9BQU8sR0FBRyxDQUFDLE1BQU0saUJBQWlCLENBQUMsR0FBRyxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsRUFBRSxLQUFLLENBQUMsQ0FBQTtZQUM1RCxDQUFDLENBQUE7UUFDRixDQUFDO0tBQ0QsQ0FBQTtBQUNGLENBQUMsQ0FBQTtBQXJCWSxRQUFBLFdBQVcsZUFxQnZCO0FBRUQsZUFBZTtBQUNmLGdEQUFnRDtBQUNoRCwyRkFBMkY7QUFDM0YsZ0ZBQWdGO0FBQ25FLFFBQUEsY0FBYyxHQUFHLElBQUEsbUJBQVcsRUFBcUMsZ0JBQVEsQ0FBQyxDQUFBO0FBQzFFLFFBQUEsZUFBZSxHQUFHLElBQUEsbUJBQVcsRUFBbUMsZ0JBQVEsQ0FBQyxDQUFBIn0=
|
package/cjs/express.d.ts
CHANGED
|
@@ -32,6 +32,32 @@ export declare const expressContext: {
|
|
|
32
32
|
jsonBeautify?: boolean | undefined;
|
|
33
33
|
disableEtag?: boolean | undefined;
|
|
34
34
|
} | undefined): <V>(next: () => V) => Promise<any>;
|
|
35
|
+
with(value: {
|
|
36
|
+
charset?: BufferEncoding | undefined;
|
|
37
|
+
jsonBeautify?: boolean | undefined;
|
|
38
|
+
disableEtag?: boolean | undefined;
|
|
39
|
+
} & ({
|
|
40
|
+
type: 'text';
|
|
41
|
+
data: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'html';
|
|
44
|
+
data: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'buffer';
|
|
47
|
+
data: Buffer;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'json';
|
|
50
|
+
data: any;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'redirect';
|
|
53
|
+
data: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'nodeStream';
|
|
56
|
+
data: Readable;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'webStream';
|
|
59
|
+
data: ReadableStream;
|
|
60
|
+
})): <V_1>(next: () => V_1) => Promise<any>;
|
|
35
61
|
};
|
|
36
62
|
export declare function setText(text: string, { status }?: {
|
|
37
63
|
status?: number;
|
package/esm/body.d.ts
CHANGED
|
@@ -5,26 +5,32 @@ export declare const bufferBodyContext: {
|
|
|
5
5
|
chain(params_0?: {
|
|
6
6
|
limit?: number | undefined;
|
|
7
7
|
} | undefined): <V>(next: () => V) => Promise<any>;
|
|
8
|
+
with(value: Buffer | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
8
9
|
};
|
|
9
10
|
export declare const jsonBodyContext: {
|
|
10
11
|
readonly value: any;
|
|
11
12
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
13
|
+
with(value: any): <V_1>(next: () => V_1) => Promise<any>;
|
|
12
14
|
};
|
|
13
15
|
export declare const rawBodyContext: {
|
|
14
16
|
readonly value: Buffer | undefined;
|
|
15
17
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
18
|
+
with(value: Buffer | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
16
19
|
};
|
|
17
20
|
export declare const textBodyContext: {
|
|
18
21
|
readonly value: string | undefined;
|
|
19
22
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
23
|
+
with(value: string | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
20
24
|
};
|
|
21
25
|
export declare const urlencodedBodyContext: {
|
|
22
26
|
readonly value: import("qs").ParsedQs | undefined;
|
|
23
27
|
chain(params_0?: {
|
|
24
28
|
simplify?: boolean | undefined;
|
|
25
29
|
} | undefined): <V>(next: () => V) => Promise<any>;
|
|
30
|
+
with(value: import("qs").ParsedQs | undefined): <V_1>(next: () => V_1) => Promise<any>;
|
|
26
31
|
};
|
|
27
32
|
export declare const queryContext: {
|
|
28
33
|
readonly value: import("qs").ParsedQs;
|
|
29
34
|
chain(): <V>(next: () => V) => Promise<any>;
|
|
35
|
+
with(value: import("qs").ParsedQs): <V_1>(next: () => V_1) => Promise<any>;
|
|
30
36
|
};
|
package/esm/context.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ import { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
4
4
|
export declare const makeContext: <T, Params extends any[] = unknown[]>(maker: (...params: Params) => Promisable<T>, end?: (result: any, value: T) => any) => {
|
|
5
5
|
readonly value: T;
|
|
6
6
|
chain(...params: Params): <V>(next: () => V) => Promise<any>;
|
|
7
|
+
with(value: T): <V_1>(next: () => V_1) => Promise<any>;
|
|
7
8
|
};
|
|
8
9
|
export declare const requestContext: {
|
|
9
10
|
readonly value: IncomingMessage;
|
|
10
11
|
chain(params_0: IncomingMessage): <V>(next: () => V) => Promise<any>;
|
|
12
|
+
with(value: IncomingMessage): <V_1>(next: () => V_1) => Promise<any>;
|
|
11
13
|
};
|
|
12
14
|
export declare const responseContext: {
|
|
13
15
|
readonly value: ServerResponse<IncomingMessage>;
|
|
14
16
|
chain(params_0: ServerResponse<IncomingMessage>): <V>(next: () => V) => Promise<any>;
|
|
17
|
+
with(value: ServerResponse<IncomingMessage>): <V_1>(next: () => V_1) => Promise<any>;
|
|
15
18
|
};
|
package/esm/context.js
CHANGED
|
@@ -12,6 +12,11 @@ export const makeContext = (maker, end = identity) => {
|
|
|
12
12
|
return end(await asyncLocalStorage.run(value, next), value);
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
|
+
with(value) {
|
|
16
|
+
return async (next) => {
|
|
17
|
+
return end(await asyncLocalStorage.run(value, next), value);
|
|
18
|
+
};
|
|
19
|
+
},
|
|
15
20
|
};
|
|
16
21
|
};
|
|
17
22
|
// method: verb
|
|
@@ -20,4 +25,4 @@ export const makeContext = (maker, end = identity) => {
|
|
|
20
25
|
// rawHeaders: list of header name and value in a flat array. Case is preserved.
|
|
21
26
|
export const requestContext = makeContext(identity);
|
|
22
27
|
export const responseContext = makeContext(identity);
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9jb250ZXh0LnRzI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ixNQUFNLENBQUMsTUFBTSxjQUFjLEdBQUcsV0FBVyxDQUFxQyxRQUFRLENBQUMsQ0FBQTtBQUN2RixNQUFNLENBQUMsTUFBTSxlQUFlLEdBQUcsV0FBVyxDQUFtQyxRQUFRLENBQUMsQ0FBQSJ9
|
package/esm/express.d.ts
CHANGED
|
@@ -32,6 +32,32 @@ export declare const expressContext: {
|
|
|
32
32
|
jsonBeautify?: boolean | undefined;
|
|
33
33
|
disableEtag?: boolean | undefined;
|
|
34
34
|
} | undefined): <V>(next: () => V) => Promise<any>;
|
|
35
|
+
with(value: {
|
|
36
|
+
charset?: BufferEncoding | undefined;
|
|
37
|
+
jsonBeautify?: boolean | undefined;
|
|
38
|
+
disableEtag?: boolean | undefined;
|
|
39
|
+
} & ({
|
|
40
|
+
type: 'text';
|
|
41
|
+
data: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'html';
|
|
44
|
+
data: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'buffer';
|
|
47
|
+
data: Buffer;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'json';
|
|
50
|
+
data: any;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'redirect';
|
|
53
|
+
data: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'nodeStream';
|
|
56
|
+
data: Readable;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'webStream';
|
|
59
|
+
data: ReadableStream;
|
|
60
|
+
})): <V_1>(next: () => V_1) => Promise<any>;
|
|
35
61
|
};
|
|
36
62
|
export declare function setText(text: string, { status }?: {
|
|
37
63
|
status?: number;
|