lambder 1.0.140 → 1.0.141
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/LambderMSW.js +3 -5
- package/package.json +1 -1
- package/src/LambderMSW.ts +5 -12
package/dist/LambderMSW.js
CHANGED
|
@@ -31,7 +31,8 @@ export default class LambderMSW {
|
|
|
31
31
|
return this.http.post(this.apiPath, async ({ request }) => {
|
|
32
32
|
let body;
|
|
33
33
|
try {
|
|
34
|
-
|
|
34
|
+
const clonedRequest = request.clone();
|
|
35
|
+
body = await clonedRequest.json();
|
|
35
36
|
}
|
|
36
37
|
catch (parseErr) {
|
|
37
38
|
// If JSON parsing fails, return undefined to let other handlers try
|
|
@@ -40,15 +41,12 @@ export default class LambderMSW {
|
|
|
40
41
|
}
|
|
41
42
|
// Check if body is valid and has apiName
|
|
42
43
|
if (!body || typeof body.apiName !== 'string') {
|
|
43
|
-
// Invalid request format, let other handlers try
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
console.log("LambderMSW called for:", body.apiName, "matching against:", apiName);
|
|
47
|
-
// Check if this is the API we're mocking
|
|
48
46
|
if (body.apiName !== apiName) {
|
|
49
|
-
// If this handler doesn't match, return undefined to let MSW try other handlers
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
49
|
+
console.log("LambderMSW called for:", body.apiName);
|
|
52
50
|
try {
|
|
53
51
|
// Add artificial delay if specified
|
|
54
52
|
if (options?.delay) {
|
package/package.json
CHANGED
package/src/LambderMSW.ts
CHANGED
|
@@ -65,7 +65,8 @@ export default class LambderMSW<TContract extends ApiContractShape = any> {
|
|
|
65
65
|
let body: any;
|
|
66
66
|
|
|
67
67
|
try {
|
|
68
|
-
|
|
68
|
+
const clonedRequest = request.clone();
|
|
69
|
+
body = await clonedRequest.json();
|
|
69
70
|
} catch (parseErr) {
|
|
70
71
|
// If JSON parsing fails, return undefined to let other handlers try
|
|
71
72
|
console.warn("LambderMSW: Failed to parse request body as JSON");
|
|
@@ -73,18 +74,10 @@ export default class LambderMSW<TContract extends ApiContractShape = any> {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
// Check if body is valid and has apiName
|
|
76
|
-
if (!body || typeof body.apiName !== 'string') {
|
|
77
|
-
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
console.log("LambderMSW called for:", body.apiName, "matching against:", apiName);
|
|
77
|
+
if (!body || typeof body.apiName !== 'string') { return; }
|
|
78
|
+
if (body.apiName !== apiName) { return; }
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
if (body.apiName !== apiName) {
|
|
85
|
-
// If this handler doesn't match, return undefined to let MSW try other handlers
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
80
|
+
console.log("LambderMSW called for:", body.apiName);
|
|
88
81
|
|
|
89
82
|
try {
|
|
90
83
|
// Add artificial delay if specified
|