@jaypie/express 1.2.16 → 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 +15 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +15 -0
- 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;
|