@jaypie/express 1.2.15 → 1.2.17
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/index.cjs +29 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +29 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -34,6 +34,21 @@ class LambdaRequest extends node_stream.Readable {
|
|
|
34
34
|
this.path = options.url.split("?")[0];
|
|
35
35
|
this.headers = this.normalizeHeaders(options.headers);
|
|
36
36
|
this.bodyBuffer = options.body ?? null;
|
|
37
|
+
// Pre-parse body: try JSON first, fall back to string.
|
|
38
|
+
// In Lambda the full body is already in memory, so we parse eagerly
|
|
39
|
+
// instead of requiring express.json() middleware. The raw stream remains
|
|
40
|
+
// available for consumers that need it (e.g. MCP transport).
|
|
41
|
+
if (this.bodyBuffer && this.bodyBuffer.length > 0) {
|
|
42
|
+
const text = this.bodyBuffer.toString("utf8");
|
|
43
|
+
try {
|
|
44
|
+
this.body = JSON.parse(text);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
this.body = text;
|
|
48
|
+
}
|
|
49
|
+
// Signal to body-parser that body is already parsed (skip reading stream)
|
|
50
|
+
this._body = true;
|
|
51
|
+
}
|
|
37
52
|
// Use pre-parsed query if provided, otherwise parse from URL
|
|
38
53
|
if (options.query) {
|
|
39
54
|
this.query = options.query;
|
|
@@ -1809,14 +1824,18 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1809
1824
|
//
|
|
1810
1825
|
// Preprocess
|
|
1811
1826
|
//
|
|
1827
|
+
// Build a request-local setup list to avoid mutating the shared array
|
|
1828
|
+
const requestSetup = [];
|
|
1812
1829
|
// Load secrets into process.env if configured
|
|
1813
1830
|
if (secrets && secrets.length > 0) {
|
|
1814
1831
|
const secretsToLoad = secrets;
|
|
1815
1832
|
const secretsSetup = async () => {
|
|
1816
1833
|
await aws.loadEnvSecrets(...secretsToLoad);
|
|
1817
1834
|
};
|
|
1818
|
-
|
|
1835
|
+
requestSetup.push(secretsSetup);
|
|
1819
1836
|
}
|
|
1837
|
+
// Add shared setup functions
|
|
1838
|
+
requestSetup.push(...setup);
|
|
1820
1839
|
if (locals) {
|
|
1821
1840
|
// Locals
|
|
1822
1841
|
const keys = Object.keys(locals);
|
|
@@ -1835,7 +1854,7 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1835
1854
|
}
|
|
1836
1855
|
}
|
|
1837
1856
|
};
|
|
1838
|
-
|
|
1857
|
+
requestSetup.push(localsSetup);
|
|
1839
1858
|
}
|
|
1840
1859
|
}
|
|
1841
1860
|
let response;
|
|
@@ -1846,7 +1865,7 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1846
1865
|
jaypieFunction = kit.jaypieHandler(handler, {
|
|
1847
1866
|
chaos,
|
|
1848
1867
|
name,
|
|
1849
|
-
setup,
|
|
1868
|
+
setup: requestSetup,
|
|
1850
1869
|
teardown,
|
|
1851
1870
|
unavailable,
|
|
1852
1871
|
validate,
|
|
@@ -2157,14 +2176,18 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2157
2176
|
//
|
|
2158
2177
|
// Preprocess
|
|
2159
2178
|
//
|
|
2179
|
+
// Build a request-local setup list to avoid mutating the shared array
|
|
2180
|
+
const requestSetup = [];
|
|
2160
2181
|
// Load secrets into process.env if configured
|
|
2161
2182
|
if (secrets && secrets.length > 0) {
|
|
2162
2183
|
const secretsToLoad = secrets;
|
|
2163
2184
|
const secretsSetup = async () => {
|
|
2164
2185
|
await aws.loadEnvSecrets(...secretsToLoad);
|
|
2165
2186
|
};
|
|
2166
|
-
|
|
2187
|
+
requestSetup.push(secretsSetup);
|
|
2167
2188
|
}
|
|
2189
|
+
// Add shared setup functions
|
|
2190
|
+
requestSetup.push(...setup);
|
|
2168
2191
|
if (locals) {
|
|
2169
2192
|
const keys = Object.keys(locals);
|
|
2170
2193
|
if (keys.length > 0) {
|
|
@@ -2182,7 +2205,7 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2182
2205
|
}
|
|
2183
2206
|
}
|
|
2184
2207
|
};
|
|
2185
|
-
|
|
2208
|
+
requestSetup.push(localsSetup);
|
|
2186
2209
|
}
|
|
2187
2210
|
}
|
|
2188
2211
|
try {
|
|
@@ -2190,7 +2213,7 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2190
2213
|
jaypieFunction = kit.jaypieHandler(handler, {
|
|
2191
2214
|
chaos,
|
|
2192
2215
|
name,
|
|
2193
|
-
setup,
|
|
2216
|
+
setup: requestSetup,
|
|
2194
2217
|
teardown,
|
|
2195
2218
|
unavailable,
|
|
2196
2219
|
validate,
|