@sveltejs/adapter-netlify 1.0.0-next.41 → 1.0.0-next.42
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/files/cjs/handler.js +22 -12
- package/files/esm/handler.js +22 -12
- package/package.json +2 -2
package/files/cjs/handler.js
CHANGED
|
@@ -20,18 +20,7 @@ function init(manifest) {
|
|
|
20
20
|
const app = new APP.App(manifest);
|
|
21
21
|
|
|
22
22
|
return async (event) => {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const encoding = isBase64Encoded ? 'base64' : 'utf-8';
|
|
26
|
-
const rawBody = typeof body === 'string' ? Buffer.from(body, encoding) : body;
|
|
27
|
-
|
|
28
|
-
const rendered = await app.render(
|
|
29
|
-
new Request(rawUrl, {
|
|
30
|
-
method: httpMethod,
|
|
31
|
-
headers: new Headers(headers),
|
|
32
|
-
body: rawBody
|
|
33
|
-
})
|
|
34
|
-
);
|
|
23
|
+
const rendered = await app.render(to_request(event));
|
|
35
24
|
|
|
36
25
|
const partial_response = {
|
|
37
26
|
statusCode: rendered.status,
|
|
@@ -57,6 +46,27 @@ function init(manifest) {
|
|
|
57
46
|
};
|
|
58
47
|
}
|
|
59
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @param {import('@netlify/functions').HandlerEvent} event
|
|
51
|
+
* @returns {Request}
|
|
52
|
+
*/
|
|
53
|
+
function to_request(event) {
|
|
54
|
+
const { httpMethod, headers, rawUrl, body, isBase64Encoded } = event;
|
|
55
|
+
|
|
56
|
+
/** @type {RequestInit} */
|
|
57
|
+
const init = {
|
|
58
|
+
method: httpMethod,
|
|
59
|
+
headers: new Headers(headers)
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (httpMethod !== 'GET' && httpMethod !== 'HEAD') {
|
|
63
|
+
const encoding = isBase64Encoded ? 'base64' : 'utf-8';
|
|
64
|
+
init.body = typeof body === 'string' ? Buffer.from(body, encoding) : body;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return new Request(rawUrl, init);
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
/**
|
|
61
71
|
* Splits headers into two categories: single value and multi value
|
|
62
72
|
* @param {Headers} headers
|
package/files/esm/handler.js
CHANGED
|
@@ -16,18 +16,7 @@ function init(manifest) {
|
|
|
16
16
|
const app = new App(manifest);
|
|
17
17
|
|
|
18
18
|
return async (event) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const encoding = isBase64Encoded ? 'base64' : 'utf-8';
|
|
22
|
-
const rawBody = typeof body === 'string' ? Buffer.from(body, encoding) : body;
|
|
23
|
-
|
|
24
|
-
const rendered = await app.render(
|
|
25
|
-
new Request(rawUrl, {
|
|
26
|
-
method: httpMethod,
|
|
27
|
-
headers: new Headers(headers),
|
|
28
|
-
body: rawBody
|
|
29
|
-
})
|
|
30
|
-
);
|
|
19
|
+
const rendered = await app.render(to_request(event));
|
|
31
20
|
|
|
32
21
|
const partial_response = {
|
|
33
22
|
statusCode: rendered.status,
|
|
@@ -53,6 +42,27 @@ function init(manifest) {
|
|
|
53
42
|
};
|
|
54
43
|
}
|
|
55
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @param {import('@netlify/functions').HandlerEvent} event
|
|
47
|
+
* @returns {Request}
|
|
48
|
+
*/
|
|
49
|
+
function to_request(event) {
|
|
50
|
+
const { httpMethod, headers, rawUrl, body, isBase64Encoded } = event;
|
|
51
|
+
|
|
52
|
+
/** @type {RequestInit} */
|
|
53
|
+
const init = {
|
|
54
|
+
method: httpMethod,
|
|
55
|
+
headers: new Headers(headers)
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (httpMethod !== 'GET' && httpMethod !== 'HEAD') {
|
|
59
|
+
const encoding = isBase64Encoded ? 'base64' : 'utf-8';
|
|
60
|
+
init.body = typeof body === 'string' ? Buffer.from(body, encoding) : body;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return new Request(rawUrl, init);
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
/**
|
|
57
67
|
* Splits headers into two categories: single value and multi value
|
|
58
68
|
* @param {Headers} headers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.42",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
34
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
34
|
+
"@sveltejs/kit": "1.0.0-next.236",
|
|
35
35
|
"rimraf": "^3.0.2",
|
|
36
36
|
"rollup": "^2.58.0"
|
|
37
37
|
},
|