@geostrategists/react-router-aws 2.1.0 → 2.1.1
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/index.js +28 -34
- package/dist/index.mjs +28 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @geostrategists/react-router-aws v2.1.
|
|
2
|
+
* @geostrategists/react-router-aws v2.1.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Geostrategists Consulting GmbH
|
|
5
5
|
*
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
"use strict";
|
|
12
|
-
var __create = Object.create;
|
|
13
12
|
var __defProp = Object.defineProperty;
|
|
14
13
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
17
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
16
|
var __export = (target, all) => {
|
|
19
17
|
for (var name in all)
|
|
@@ -27,14 +25,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
25
|
}
|
|
28
26
|
return to;
|
|
29
27
|
};
|
|
30
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
-
mod
|
|
37
|
-
));
|
|
38
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
29
|
|
|
40
30
|
// src/index.ts
|
|
@@ -149,28 +139,29 @@ function createReactRouterHeadersAPIGatewayV2(requestHeaders, requestCookies) {
|
|
|
149
139
|
}
|
|
150
140
|
return headers;
|
|
151
141
|
}
|
|
152
|
-
|
|
142
|
+
function extractAPIGatewayV2ResponseMetadata(nodeResponse) {
|
|
153
143
|
const cookies = nodeResponse.headers.getSetCookie();
|
|
154
144
|
if (cookies.length) {
|
|
155
145
|
nodeResponse.headers.delete("Set-Cookie");
|
|
156
146
|
}
|
|
147
|
+
return {
|
|
148
|
+
statusCode: nodeResponse.status,
|
|
149
|
+
headers: Object.fromEntries(nodeResponse.headers.entries()),
|
|
150
|
+
cookies
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
async function sendReactRouterResponseAPIGatewayV2(nodeResponse) {
|
|
154
|
+
const result = extractAPIGatewayV2ResponseMetadata(nodeResponse);
|
|
157
155
|
const contentType = nodeResponse.headers.get("Content-Type");
|
|
158
|
-
|
|
159
|
-
let body;
|
|
156
|
+
result.isBase64Encoded = isBinaryType(contentType);
|
|
160
157
|
if (nodeResponse.body) {
|
|
161
|
-
if (isBase64Encoded) {
|
|
162
|
-
body = await (0, import_node.readableStreamToString)(nodeResponse.body, "base64");
|
|
158
|
+
if (result.isBase64Encoded) {
|
|
159
|
+
result.body = await (0, import_node.readableStreamToString)(nodeResponse.body, "base64");
|
|
163
160
|
} else {
|
|
164
|
-
body = await nodeResponse.text();
|
|
161
|
+
result.body = await nodeResponse.text();
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
|
-
return
|
|
168
|
-
statusCode: nodeResponse.status,
|
|
169
|
-
headers: Object.fromEntries(nodeResponse.headers.entries()),
|
|
170
|
-
cookies,
|
|
171
|
-
body,
|
|
172
|
-
isBase64Encoded
|
|
173
|
-
};
|
|
164
|
+
return result;
|
|
174
165
|
}
|
|
175
166
|
var apiGatewayV2Adapter = {
|
|
176
167
|
wrapHandler: (handler) => (e) => handler(e),
|
|
@@ -283,21 +274,24 @@ var applicationLoadBalancerAdapter = {
|
|
|
283
274
|
|
|
284
275
|
// src/adapters/function-url-streaming.ts
|
|
285
276
|
var import_node4 = require("@react-router/node");
|
|
286
|
-
var
|
|
277
|
+
var emptyStream = () => new ReadableStream({
|
|
278
|
+
start(controller) {
|
|
279
|
+
controller.enqueue("");
|
|
280
|
+
controller.close();
|
|
281
|
+
}
|
|
282
|
+
});
|
|
287
283
|
var sendReactRouterResponseFunctionUrlStreaming = async (response, responseStream) => {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (response.body) {
|
|
293
|
-
await (0, import_node4.writeReadableStreamToWritable)(response.body, httpResponseStream);
|
|
294
|
-
} else {
|
|
295
|
-
await import_promises.default.finished(httpResponseStream);
|
|
284
|
+
const metadata = extractAPIGatewayV2ResponseMetadata(response);
|
|
285
|
+
let body = response.body;
|
|
286
|
+
if (!body) {
|
|
287
|
+
body = emptyStream();
|
|
296
288
|
}
|
|
289
|
+
const httpResponseStream = awslambda.HttpResponseStream.from(responseStream, metadata);
|
|
290
|
+
await (0, import_node4.writeReadableStreamToWritable)(body, httpResponseStream);
|
|
297
291
|
};
|
|
298
292
|
var functionUrlStreamingAdapter = {
|
|
299
293
|
wrapHandler: awslambda.streamifyResponse,
|
|
300
|
-
createReactRouterRequest:
|
|
294
|
+
createReactRouterRequest: createReactRouterRequestAPIGateywayV2,
|
|
301
295
|
sendReactRouterResponse: sendReactRouterResponseFunctionUrlStreaming
|
|
302
296
|
};
|
|
303
297
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @geostrategists/react-router-aws v2.1.
|
|
2
|
+
* @geostrategists/react-router-aws v2.1.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Geostrategists Consulting GmbH
|
|
5
5
|
*
|
|
@@ -110,28 +110,29 @@ function createReactRouterHeadersAPIGatewayV2(requestHeaders, requestCookies) {
|
|
|
110
110
|
}
|
|
111
111
|
return headers;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
function extractAPIGatewayV2ResponseMetadata(nodeResponse) {
|
|
114
114
|
const cookies = nodeResponse.headers.getSetCookie();
|
|
115
115
|
if (cookies.length) {
|
|
116
116
|
nodeResponse.headers.delete("Set-Cookie");
|
|
117
117
|
}
|
|
118
|
+
return {
|
|
119
|
+
statusCode: nodeResponse.status,
|
|
120
|
+
headers: Object.fromEntries(nodeResponse.headers.entries()),
|
|
121
|
+
cookies
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async function sendReactRouterResponseAPIGatewayV2(nodeResponse) {
|
|
125
|
+
const result = extractAPIGatewayV2ResponseMetadata(nodeResponse);
|
|
118
126
|
const contentType = nodeResponse.headers.get("Content-Type");
|
|
119
|
-
|
|
120
|
-
let body;
|
|
127
|
+
result.isBase64Encoded = isBinaryType(contentType);
|
|
121
128
|
if (nodeResponse.body) {
|
|
122
|
-
if (isBase64Encoded) {
|
|
123
|
-
body = await readableStreamToString(nodeResponse.body, "base64");
|
|
129
|
+
if (result.isBase64Encoded) {
|
|
130
|
+
result.body = await readableStreamToString(nodeResponse.body, "base64");
|
|
124
131
|
} else {
|
|
125
|
-
body = await nodeResponse.text();
|
|
132
|
+
result.body = await nodeResponse.text();
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
|
-
return
|
|
129
|
-
statusCode: nodeResponse.status,
|
|
130
|
-
headers: Object.fromEntries(nodeResponse.headers.entries()),
|
|
131
|
-
cookies,
|
|
132
|
-
body,
|
|
133
|
-
isBase64Encoded
|
|
134
|
-
};
|
|
135
|
+
return result;
|
|
135
136
|
}
|
|
136
137
|
var apiGatewayV2Adapter = {
|
|
137
138
|
wrapHandler: (handler) => (e) => handler(e),
|
|
@@ -244,21 +245,24 @@ var applicationLoadBalancerAdapter = {
|
|
|
244
245
|
|
|
245
246
|
// src/adapters/function-url-streaming.ts
|
|
246
247
|
import { writeReadableStreamToWritable } from "@react-router/node";
|
|
247
|
-
|
|
248
|
+
var emptyStream = () => new ReadableStream({
|
|
249
|
+
start(controller) {
|
|
250
|
+
controller.enqueue("");
|
|
251
|
+
controller.close();
|
|
252
|
+
}
|
|
253
|
+
});
|
|
248
254
|
var sendReactRouterResponseFunctionUrlStreaming = async (response, responseStream) => {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (response.body) {
|
|
254
|
-
await writeReadableStreamToWritable(response.body, httpResponseStream);
|
|
255
|
-
} else {
|
|
256
|
-
await stream.finished(httpResponseStream);
|
|
255
|
+
const metadata = extractAPIGatewayV2ResponseMetadata(response);
|
|
256
|
+
let body = response.body;
|
|
257
|
+
if (!body) {
|
|
258
|
+
body = emptyStream();
|
|
257
259
|
}
|
|
260
|
+
const httpResponseStream = awslambda.HttpResponseStream.from(responseStream, metadata);
|
|
261
|
+
await writeReadableStreamToWritable(body, httpResponseStream);
|
|
258
262
|
};
|
|
259
263
|
var functionUrlStreamingAdapter = {
|
|
260
264
|
wrapHandler: awslambda.streamifyResponse,
|
|
261
|
-
createReactRouterRequest:
|
|
265
|
+
createReactRouterRequest: createReactRouterRequestAPIGateywayV2,
|
|
262
266
|
sendReactRouterResponse: sendReactRouterResponseFunctionUrlStreaming
|
|
263
267
|
};
|
|
264
268
|
|