@yopdev/dev-server 1.3.9 → 1.3.10
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.
|
@@ -5,7 +5,7 @@ import { Service, Callback } from "./services";
|
|
|
5
5
|
export declare const newLambdaHttpProxy: (name: string, config: {
|
|
6
6
|
settings: HttpSettings;
|
|
7
7
|
routes: Route[];
|
|
8
|
-
mapper?: (request: IncomingMessage, body: string) => APIGatewayProxyEvent
|
|
8
|
+
mapper?: (request: IncomingMessage, body: string) => Promise<APIGatewayProxyEvent>;
|
|
9
9
|
}, callback?: Callback<string>) => Service<string>;
|
|
10
10
|
export type Route = {
|
|
11
11
|
method: RegExp;
|
|
@@ -54,14 +54,17 @@ var LambdaHttpProxy = /** @class */ (function () {
|
|
|
54
54
|
this.stop = function () { return _this.server.stop(); };
|
|
55
55
|
this.handler = function (lambdaHandler) {
|
|
56
56
|
return function (request, body, response) {
|
|
57
|
-
return
|
|
58
|
-
.then(function (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
return _this.mapper(request, body)
|
|
58
|
+
.then(function (mapper) {
|
|
59
|
+
return lambdaHandler(mapper)
|
|
60
|
+
.then(function (lambda) {
|
|
61
|
+
var _a, _b, _c, _d, _e, _f;
|
|
62
|
+
return (0, responses_1.writeResponse)(response, lambda.statusCode, lambda.body, (_c = (_b = (_a = lambda.headers) === null || _a === void 0 ? void 0 : _a['Content-Type']) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : undefined, (_f = (_e = (_d = lambda.headers) === null || _d === void 0 ? void 0 : _d['Location']) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : undefined);
|
|
63
|
+
})
|
|
64
|
+
.catch(function (e) {
|
|
65
|
+
_this.LOGGER.error(e, 'request failed to execute');
|
|
66
|
+
(0, responses_1.internalServerError)(response, e.body);
|
|
67
|
+
});
|
|
65
68
|
});
|
|
66
69
|
};
|
|
67
70
|
};
|
package/dist/src/mappers.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { Message } from "@aws-sdk/client-sqs";
|
|
|
3
3
|
import { APIGatewayProxyEvent, SQSRecord } from "aws-lambda";
|
|
4
4
|
import { IncomingMessage } from "http";
|
|
5
5
|
export declare const mapToLambdaSqsRecord: (message: Message) => SQSRecord;
|
|
6
|
-
export declare function mapToLambdaEvent(req: IncomingMessage, requestBody: string): APIGatewayProxyEvent
|
|
6
|
+
export declare function mapToLambdaEvent(req: IncomingMessage, requestBody: string): Promise<APIGatewayProxyEvent>;
|
package/dist/src/mappers.js
CHANGED
|
@@ -39,7 +39,7 @@ function mapToLambdaEvent(req, requestBody) {
|
|
|
39
39
|
headers['accept'] = req.headers['accept'];
|
|
40
40
|
if (req.headers['authorization'])
|
|
41
41
|
headers['authorization'] = req.headers['authorization'];
|
|
42
|
-
return {
|
|
42
|
+
return Promise.resolve({
|
|
43
43
|
httpMethod: req.method,
|
|
44
44
|
body: requestBody,
|
|
45
45
|
headers: headers,
|
|
@@ -87,7 +87,7 @@ function mapToLambdaEvent(req, requestBody) {
|
|
|
87
87
|
resourcePath: '',
|
|
88
88
|
stage: '',
|
|
89
89
|
},
|
|
90
|
-
};
|
|
90
|
+
});
|
|
91
91
|
}
|
|
92
92
|
exports.mapToLambdaEvent = mapToLambdaEvent;
|
|
93
93
|
function extractClaims(req) {
|