Skip to content

Commit 7d19e39

Browse files
committed
fix: add logging for requests and responses
1 parent 1682f64 commit 7d19e39

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

lambda/serverless.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,37 @@ export async function handler(event, context) {
3131
env: process.env,
3232
})
3333

34-
//Render the app
35-
const rendered = await app.respond(
36-
new Request(rawURL, {
37-
method: requestContext.http.method,
38-
headers: new Headers(headers),
39-
body: rawBody,
40-
}),
41-
{
42-
platform: { context },
43-
}
44-
)
34+
// Render the app
35+
const request = new Request(rawURL, {
36+
method: requestContext.http.method,
37+
headers: new Headers(headers),
38+
body: rawBody,
39+
})
40+
console.log(request)
41+
42+
const rendered = await app.respond(request, {
43+
platform: { context },
44+
})
45+
46+
// Parse the response into lambda proxy response
47+
let response
4548

46-
//Parse the response into lambda proxy response
4749
if (rendered) {
48-
const resp = {
50+
response = {
4951
...split_headers(rendered.headers),
5052
body: await rendered.text(),
5153
statusCode: rendered.status,
5254
}
53-
resp.headers['cache-control'] = 'no-cache'
54-
return resp
55-
}
56-
return {
57-
statusCode: 404,
58-
body: 'Not found.',
55+
response.headers['cache-control'] = 'no-cache'
56+
} else {
57+
response = {
58+
statusCode: 404,
59+
body: 'Not found.',
60+
}
5961
}
62+
console.log(response)
63+
64+
return response
6065
}
6166

6267
// Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors) (MIT)

0 commit comments

Comments
 (0)