@fintalk.ai/lambda-handlers 1.0.3 → 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/README.md +62 -20
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +10 -0
- package/lib/constants.js.map +1 -0
- package/lib/errors/bad-request-error.d.ts +4 -0
- package/lib/errors/bad-request-error.js +35 -0
- package/lib/errors/bad-request-error.js.map +1 -0
- package/lib/errors/conflict-error.d.ts +4 -0
- package/lib/errors/conflict-error.js +35 -0
- package/lib/errors/conflict-error.js.map +1 -0
- package/lib/errors/fintalk-error.d.ts +41 -0
- package/lib/errors/fintalk-error.js +55 -0
- package/lib/errors/fintalk-error.js.map +1 -0
- package/lib/errors/forbidden-error.d.ts +4 -0
- package/lib/errors/forbidden-error.js +35 -0
- package/lib/errors/forbidden-error.js.map +1 -0
- package/lib/errors/gone-error.d.ts +4 -0
- package/lib/errors/gone-error.js +35 -0
- package/lib/errors/gone-error.js.map +1 -0
- package/lib/errors/internal-server-error.d.ts +4 -0
- package/lib/errors/internal-server-error.js +35 -0
- package/lib/errors/internal-server-error.js.map +1 -0
- package/lib/errors/not-acceptable-error.d.ts +4 -0
- package/lib/errors/not-acceptable-error.js +35 -0
- package/lib/errors/not-acceptable-error.js.map +1 -0
- package/lib/errors/not-found-error.d.ts +4 -0
- package/lib/errors/not-found-error.js +35 -0
- package/lib/errors/not-found-error.js.map +1 -0
- package/lib/errors/payment-required-error.d.ts +4 -0
- package/lib/errors/payment-required-error.js +35 -0
- package/lib/errors/payment-required-error.js.map +1 -0
- package/lib/errors/precondition-failed-error.d.ts +4 -0
- package/lib/errors/precondition-failed-error.js +35 -0
- package/lib/errors/precondition-failed-error.js.map +1 -0
- package/lib/errors/service-unavailable-error.d.ts +4 -0
- package/lib/errors/service-unavailable-error.js +35 -0
- package/lib/errors/service-unavailable-error.js.map +1 -0
- package/lib/errors/teapot-error.d.ts +4 -0
- package/lib/errors/teapot-error.js +35 -0
- package/lib/errors/teapot-error.js.map +1 -0
- package/lib/errors/too-many-requests-error.d.ts +4 -0
- package/lib/errors/too-many-requests-error.js +35 -0
- package/lib/errors/too-many-requests-error.js.map +1 -0
- package/lib/errors/unauthorized-error.d.ts +4 -0
- package/lib/errors/unauthorized-error.js +35 -0
- package/lib/errors/unauthorized-error.js.map +1 -0
- package/lib/errors/unprocessable-entity-error.d.ts +4 -0
- package/lib/errors/unprocessable-entity-error.js +35 -0
- package/lib/errors/unprocessable-entity-error.js.map +1 -0
- package/lib/errors/websocket-error.d.ts +40 -0
- package/lib/errors/websocket-error.js +54 -0
- package/lib/errors/websocket-error.js.map +1 -0
- package/lib/handlers/api-proxy.d.ts +13 -0
- package/lib/handlers/api-proxy.js +257 -0
- package/lib/handlers/api-proxy.js.map +1 -0
- package/lib/handlers/api.d.ts +11 -0
- package/lib/handlers/api.js +198 -0
- package/lib/handlers/api.js.map +1 -0
- package/lib/handlers/authorizer.d.ts +7 -0
- package/lib/handlers/authorizer.js +181 -0
- package/lib/handlers/authorizer.js.map +1 -0
- package/lib/handlers/cloudwatch.d.ts +7 -0
- package/lib/handlers/cloudwatch.js +143 -0
- package/lib/handlers/cloudwatch.js.map +1 -0
- package/lib/handlers/invoke.d.ts +13 -0
- package/lib/handlers/invoke.js +158 -0
- package/lib/handlers/invoke.js.map +1 -0
- package/lib/handlers/kinesis.d.ts +13 -0
- package/lib/handlers/kinesis.js +193 -0
- package/lib/handlers/kinesis.js.map +1 -0
- package/lib/handlers/lambda-proxy/index.d.ts +8 -0
- package/lib/handlers/lambda-proxy/index.js +182 -0
- package/lib/handlers/lambda-proxy/index.js.map +1 -0
- package/lib/handlers/lambda-proxy/validate-event-data.d.ts +3 -0
- package/lib/handlers/lambda-proxy/validate-event-data.js +26 -0
- package/lib/handlers/lambda-proxy/validate-event-data.js.map +1 -0
- package/lib/handlers/sqs-v2.d.ts +23 -0
- package/lib/handlers/sqs-v2.js +227 -0
- package/lib/handlers/sqs-v2.js.map +1 -0
- package/lib/handlers/sqs.d.ts +16 -0
- package/lib/handlers/sqs.js +179 -0
- package/lib/handlers/sqs.js.map +1 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +72 -0
- package/lib/index.js.map +1 -0
- package/lib/models.d.ts +78 -0
- package/lib/models.js +3 -0
- package/lib/models.js.map +1 -0
- package/lib/utils/check-envs.d.ts +3 -0
- package/lib/utils/check-envs.js +14 -0
- package/lib/utils/check-envs.js.map +1 -0
- package/lib/utils/compare-ignore-case.d.ts +2 -0
- package/lib/utils/compare-ignore-case.js +10 -0
- package/lib/utils/compare-ignore-case.js.map +1 -0
- package/lib/utils/convert-query-string.d.ts +3 -0
- package/lib/utils/convert-query-string.js +18 -0
- package/lib/utils/convert-query-string.js.map +1 -0
- package/lib/utils/extract-ip.d.ts +3 -0
- package/lib/utils/extract-ip.js +12 -0
- package/lib/utils/extract-ip.js.map +1 -0
- package/lib/utils/extract-queue-name.d.ts +2 -0
- package/lib/utils/extract-queue-name.js +9 -0
- package/lib/utils/extract-queue-name.js.map +1 -0
- package/lib/utils/extract-user.d.ts +4 -0
- package/lib/utils/extract-user.js +57 -0
- package/lib/utils/extract-user.js.map +1 -0
- package/lib/utils/find-path.d.ts +2 -0
- package/lib/utils/find-path.js +14 -0
- package/lib/utils/find-path.js.map +1 -0
- package/lib/utils/get-user-id.d.ts +3 -0
- package/lib/utils/get-user-id.js +18 -0
- package/lib/utils/get-user-id.js.map +1 -0
- package/lib/utils/json-parse.d.ts +2 -0
- package/lib/utils/json-parse.js +27 -0
- package/lib/utils/json-parse.js.map +1 -0
- package/lib/utils/kinesis-parse.d.ts +2 -0
- package/lib/utils/kinesis-parse.js +14 -0
- package/lib/utils/kinesis-parse.js.map +1 -0
- package/lib/utils/lower-case-headers.d.ts +3 -0
- package/lib/utils/lower-case-headers.js +22 -0
- package/lib/utils/lower-case-headers.js.map +1 -0
- package/lib/utils/parse-authorizer-request.d.ts +4 -0
- package/lib/utils/parse-authorizer-request.js +32 -0
- package/lib/utils/parse-authorizer-request.js.map +1 -0
- package/lib/utils/parse-body.d.ts +2 -0
- package/lib/utils/parse-body.js +19 -0
- package/lib/utils/parse-body.js.map +1 -0
- package/lib/utils/parse-path-params.d.ts +2 -0
- package/lib/utils/parse-path-params.js +14 -0
- package/lib/utils/parse-path-params.js.map +1 -0
- package/lib/utils/parse-request.d.ts +4 -0
- package/lib/utils/parse-request.js +35 -0
- package/lib/utils/parse-request.js.map +1 -0
- package/lib/utils/provider-flush.d.ts +4 -0
- package/lib/utils/provider-flush.js +81 -0
- package/lib/utils/provider-flush.js.map +1 -0
- package/lib/utils/sleep.d.ts +2 -0
- package/lib/utils/sleep.js +7 -0
- package/lib/utils/sleep.js.map +1 -0
- package/package.json +25 -36
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var fintalk_error_1 = __importDefault(require("./fintalk-error"));
|
|
22
|
+
var PreconditionFailedError = (function (_super) {
|
|
23
|
+
__extends(PreconditionFailedError, _super);
|
|
24
|
+
function PreconditionFailedError(message, details, user_error_code) {
|
|
25
|
+
if (message === void 0) { message = 'Precondition Failed'; }
|
|
26
|
+
if (details === void 0) { details = []; }
|
|
27
|
+
if (user_error_code === void 0) { user_error_code = ''; }
|
|
28
|
+
var _this = _super.call(this, message, 412, details, user_error_code) || this;
|
|
29
|
+
Object.setPrototypeOf(_this, PreconditionFailedError.prototype);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return PreconditionFailedError;
|
|
33
|
+
}(fintalk_error_1.default));
|
|
34
|
+
exports.default = PreconditionFailedError;
|
|
35
|
+
//# sourceMappingURL=precondition-failed-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precondition-failed-error.js","sourceRoot":"","sources":["../../src/errors/precondition-failed-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAE1C;IAAqD,2CAAY;IAC/D,iCACE,OAAuC,EACvC,OAAmB,EACnB,eAA4B;QAF5B,wBAAA,EAAA,+BAAuC;QACvC,wBAAA,EAAA,YAAmB;QACnB,gCAAA,EAAA,oBAA4B;QAH9B,YAKE,kBAAM,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,SAE9C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;;IAChE,CAAC;IACH,8BAAC;AAAD,CAAC,AATD,CAAqD,uBAAY,GAShE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var fintalk_error_1 = __importDefault(require("./fintalk-error"));
|
|
22
|
+
var ServiceUnavailableError = (function (_super) {
|
|
23
|
+
__extends(ServiceUnavailableError, _super);
|
|
24
|
+
function ServiceUnavailableError(message, details, user_error_code) {
|
|
25
|
+
if (message === void 0) { message = 'Service Unavailable'; }
|
|
26
|
+
if (details === void 0) { details = []; }
|
|
27
|
+
if (user_error_code === void 0) { user_error_code = ''; }
|
|
28
|
+
var _this = _super.call(this, message, 503, details, user_error_code) || this;
|
|
29
|
+
Object.setPrototypeOf(_this, ServiceUnavailableError.prototype);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return ServiceUnavailableError;
|
|
33
|
+
}(fintalk_error_1.default));
|
|
34
|
+
exports.default = ServiceUnavailableError;
|
|
35
|
+
//# sourceMappingURL=service-unavailable-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-unavailable-error.js","sourceRoot":"","sources":["../../src/errors/service-unavailable-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAE1C;IAAqD,2CAAY;IAC/D,iCACE,OAAuC,EACvC,OAAmB,EACnB,eAA4B;QAF5B,wBAAA,EAAA,+BAAuC;QACvC,wBAAA,EAAA,YAAmB;QACnB,gCAAA,EAAA,oBAA4B;QAH9B,YAKE,kBAAM,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,SAE9C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;;IAChE,CAAC;IACH,8BAAC;AAAD,CAAC,AATD,CAAqD,uBAAY,GAShE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var fintalk_error_1 = __importDefault(require("./fintalk-error"));
|
|
22
|
+
var TeapotError = (function (_super) {
|
|
23
|
+
__extends(TeapotError, _super);
|
|
24
|
+
function TeapotError(message, details, user_error_code) {
|
|
25
|
+
if (message === void 0) { message = 'ImAHoneyPot'; }
|
|
26
|
+
if (details === void 0) { details = []; }
|
|
27
|
+
if (user_error_code === void 0) { user_error_code = ''; }
|
|
28
|
+
var _this = _super.call(this, message, 418, details, user_error_code) || this;
|
|
29
|
+
Object.setPrototypeOf(_this, TeapotError.prototype);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return TeapotError;
|
|
33
|
+
}(fintalk_error_1.default));
|
|
34
|
+
exports.default = TeapotError;
|
|
35
|
+
//# sourceMappingURL=teapot-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teapot-error.js","sourceRoot":"","sources":["../../src/errors/teapot-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAE1C;IAAyC,+BAAY;IACnD,qBACE,OAA+B,EAC/B,OAAmB,EACnB,eAA4B;QAF5B,wBAAA,EAAA,uBAA+B;QAC/B,wBAAA,EAAA,YAAmB;QACnB,gCAAA,EAAA,oBAA4B;QAH9B,YAKE,kBAAM,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,SAE9C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;;IACpD,CAAC;IACH,kBAAC;AAAD,CAAC,AATD,CAAyC,uBAAY,GASpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var fintalk_error_1 = __importDefault(require("./fintalk-error"));
|
|
22
|
+
var TooManyRequestsError = (function (_super) {
|
|
23
|
+
__extends(TooManyRequestsError, _super);
|
|
24
|
+
function TooManyRequestsError(message, details, user_error_code) {
|
|
25
|
+
if (message === void 0) { message = 'Too Many Requests'; }
|
|
26
|
+
if (details === void 0) { details = []; }
|
|
27
|
+
if (user_error_code === void 0) { user_error_code = ''; }
|
|
28
|
+
var _this = _super.call(this, message, 429, details, user_error_code) || this;
|
|
29
|
+
Object.setPrototypeOf(_this, TooManyRequestsError.prototype);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return TooManyRequestsError;
|
|
33
|
+
}(fintalk_error_1.default));
|
|
34
|
+
exports.default = TooManyRequestsError;
|
|
35
|
+
//# sourceMappingURL=too-many-requests-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"too-many-requests-error.js","sourceRoot":"","sources":["../../src/errors/too-many-requests-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAE1C;IAAkD,wCAAY;IAC5D,8BACE,OAAqC,EACrC,OAAmB,EACnB,eAA4B;QAF5B,wBAAA,EAAA,6BAAqC;QACrC,wBAAA,EAAA,YAAmB;QACnB,gCAAA,EAAA,oBAA4B;QAH9B,YAKE,kBAAM,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,SAE9C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAA;;IAC7D,CAAC;IACH,2BAAC;AAAD,CAAC,AATD,CAAkD,uBAAY,GAS7D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var fintalk_error_1 = __importDefault(require("./fintalk-error"));
|
|
22
|
+
var UnauthorizedError = (function (_super) {
|
|
23
|
+
__extends(UnauthorizedError, _super);
|
|
24
|
+
function UnauthorizedError(message, details, user_error_code) {
|
|
25
|
+
if (message === void 0) { message = 'Unauthorized'; }
|
|
26
|
+
if (details === void 0) { details = []; }
|
|
27
|
+
if (user_error_code === void 0) { user_error_code = ''; }
|
|
28
|
+
var _this = _super.call(this, message, 401, details, user_error_code) || this;
|
|
29
|
+
Object.setPrototypeOf(_this, UnauthorizedError.prototype);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return UnauthorizedError;
|
|
33
|
+
}(fintalk_error_1.default));
|
|
34
|
+
exports.default = UnauthorizedError;
|
|
35
|
+
//# sourceMappingURL=unauthorized-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthorized-error.js","sourceRoot":"","sources":["../../src/errors/unauthorized-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAE1C;IAA+C,qCAAY;IACzD,2BACE,OAAgC,EAChC,OAAmB,EACnB,eAA4B;QAF5B,wBAAA,EAAA,wBAAgC;QAChC,wBAAA,EAAA,YAAmB;QACnB,gCAAA,EAAA,oBAA4B;QAH9B,YAKE,kBAAM,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,SAE9C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;;IAC1D,CAAC;IACH,wBAAC;AAAD,CAAC,AATD,CAA+C,uBAAY,GAS1D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var fintalk_error_1 = __importDefault(require("./fintalk-error"));
|
|
22
|
+
var UnprocessableEntityError = (function (_super) {
|
|
23
|
+
__extends(UnprocessableEntityError, _super);
|
|
24
|
+
function UnprocessableEntityError(message, details, user_error_code) {
|
|
25
|
+
if (message === void 0) { message = 'Unprocessable Entity'; }
|
|
26
|
+
if (details === void 0) { details = []; }
|
|
27
|
+
if (user_error_code === void 0) { user_error_code = ''; }
|
|
28
|
+
var _this = _super.call(this, message, 422, details, user_error_code) || this;
|
|
29
|
+
Object.setPrototypeOf(_this, UnprocessableEntityError.prototype);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return UnprocessableEntityError;
|
|
33
|
+
}(fintalk_error_1.default));
|
|
34
|
+
exports.default = UnprocessableEntityError;
|
|
35
|
+
//# sourceMappingURL=unprocessable-entity-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unprocessable-entity-error.js","sourceRoot":"","sources":["../../src/errors/unprocessable-entity-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAE1C;IAAsD,4CAAY;IAChE,kCACE,OAAwC,EACxC,OAAmB,EACnB,eAA4B;QAF5B,wBAAA,EAAA,gCAAwC;QACxC,wBAAA,EAAA,YAAmB;QACnB,gCAAA,EAAA,oBAA4B;QAH9B,YAKE,kBAAM,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,SAE9C;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;;IACjE,CAAC;IACH,+BAAC;AAAD,CAAC,AATD,CAAsD,uBAAY,GASjE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default class WebsocketError extends Error {
|
|
2
|
+
isTreated: boolean;
|
|
3
|
+
code: number;
|
|
4
|
+
details?: any;
|
|
5
|
+
constructor(message: string, code?: number, details?: any);
|
|
6
|
+
getDetails(): {
|
|
7
|
+
details?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
details: any;
|
|
10
|
+
};
|
|
11
|
+
toObject(): {
|
|
12
|
+
error: boolean;
|
|
13
|
+
status: number;
|
|
14
|
+
body: {
|
|
15
|
+
details?: undefined;
|
|
16
|
+
code: number;
|
|
17
|
+
message: string;
|
|
18
|
+
} | {
|
|
19
|
+
details: any;
|
|
20
|
+
code: number;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
details?: undefined;
|
|
24
|
+
name: string;
|
|
25
|
+
} | {
|
|
26
|
+
error: boolean;
|
|
27
|
+
status: number;
|
|
28
|
+
body: {
|
|
29
|
+
details?: undefined;
|
|
30
|
+
code: number;
|
|
31
|
+
message: string;
|
|
32
|
+
} | {
|
|
33
|
+
details: any;
|
|
34
|
+
code: number;
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
details: any;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
var WebsocketError = (function (_super) {
|
|
30
|
+
__extends(WebsocketError, _super);
|
|
31
|
+
function WebsocketError(message, code, details) {
|
|
32
|
+
var _this = _super.call(this, message) || this;
|
|
33
|
+
_this.isTreated = true;
|
|
34
|
+
_this.message = message;
|
|
35
|
+
_this.code = code || 400;
|
|
36
|
+
_this.details = details;
|
|
37
|
+
Object.setPrototypeOf(_this, WebsocketError.prototype);
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
WebsocketError.prototype.getDetails = function () {
|
|
41
|
+
if (!this.details) {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
details: this.details,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
WebsocketError.prototype.toObject = function () {
|
|
49
|
+
return __assign(__assign({ name: this.message }, this.getDetails()), { error: true, status: this.code, body: __assign({ code: this.code, message: this.message }, this.getDetails()) });
|
|
50
|
+
};
|
|
51
|
+
return WebsocketError;
|
|
52
|
+
}(Error));
|
|
53
|
+
exports.default = WebsocketError;
|
|
54
|
+
//# sourceMappingURL=websocket-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-error.js","sourceRoot":"","sources":["../../src/errors/websocket-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;IAA4C,kCAAK;IAK/C,wBAAa,OAAe,EAAE,IAAa,EAAE,OAAa;QAA1D,YACE,kBAAM,OAAO,CAAC,SAQf;QANC,KAAI,CAAC,SAAS,GAAG,IAAI,CAAA;QACrB,KAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,KAAI,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAA;QACvB,KAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QAEtB,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;;IACvD,CAAC;IAED,mCAAU,GAAV;QACE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,EAAE,CAAA;SACV;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;IACH,CAAC;IAED,iCAAQ,GAAR;QACE,2BACE,IAAI,EAAE,IAAI,CAAC,OAAO,IACf,IAAI,CAAC,UAAU,EAAE,KACpB,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,CAAC,IAAI,EACjB,IAAI,aACF,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAClB,IAAI,CAAC,UAAU,EAAE,KAEvB;IACH,CAAC;IACH,qBAAC;AAAD,CAAC,AAvCD,CAA4C,KAAK,GAuChD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
|
2
|
+
import { Options, Route } from '../models';
|
|
3
|
+
export declare class LambdaApiProxyHandler {
|
|
4
|
+
readonly base: string;
|
|
5
|
+
readonly routes: Route[];
|
|
6
|
+
constructor(options?: Options);
|
|
7
|
+
addRoute(route: Route): void;
|
|
8
|
+
corsObject(event: APIGatewayProxyEvent, headers: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
}): APIGatewayProxyResult;
|
|
11
|
+
findRoute(event: APIGatewayProxyEvent): Route | undefined;
|
|
12
|
+
handler(event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.LambdaApiProxyHandler = void 0;
|
|
54
|
+
var api_1 = require("@opentelemetry/api");
|
|
55
|
+
var core_1 = require("@opentelemetry/core");
|
|
56
|
+
var semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
57
|
+
var otlp_1 = require("@stone-ton/otlp");
|
|
58
|
+
var fintalk_logger_1 = __importDefault(require("fintalk-logger"));
|
|
59
|
+
var node_match_path_1 = require("node-match-path");
|
|
60
|
+
var constants_1 = require("../constants");
|
|
61
|
+
var not_found_error_1 = __importDefault(require("../errors/not-found-error"));
|
|
62
|
+
var check_envs_1 = __importDefault(require("../utils/check-envs"));
|
|
63
|
+
var compare_ignore_case_1 = __importDefault(require("../utils/compare-ignore-case"));
|
|
64
|
+
var convert_query_string_1 = __importDefault(require("../utils/convert-query-string"));
|
|
65
|
+
var parse_request_1 = __importDefault(require("../utils/parse-request"));
|
|
66
|
+
var provider_flush_1 = __importDefault(require("../utils/provider-flush"));
|
|
67
|
+
var LambdaApiProxyHandler = (function () {
|
|
68
|
+
function LambdaApiProxyHandler(options) {
|
|
69
|
+
this.routes = [];
|
|
70
|
+
this.base = options
|
|
71
|
+
&& options.base
|
|
72
|
+
&& typeof options.base === 'string'
|
|
73
|
+
? options.base.trim()
|
|
74
|
+
: '';
|
|
75
|
+
}
|
|
76
|
+
LambdaApiProxyHandler.prototype.addRoute = function (route) {
|
|
77
|
+
this.routes.push(__assign(__assign({}, route), { path: "".concat(this.base).concat(route.path) }));
|
|
78
|
+
};
|
|
79
|
+
LambdaApiProxyHandler.prototype.corsObject = function (event, headers) {
|
|
80
|
+
var route = this.routes.find(function (_a) {
|
|
81
|
+
var path = _a.path;
|
|
82
|
+
var matches = (0, node_match_path_1.match)(path, event.path).matches;
|
|
83
|
+
return matches;
|
|
84
|
+
});
|
|
85
|
+
if (!route) {
|
|
86
|
+
fintalk_logger_1.default.warn({
|
|
87
|
+
message: 'Route not found',
|
|
88
|
+
path: event.path,
|
|
89
|
+
method: event.httpMethod,
|
|
90
|
+
});
|
|
91
|
+
throw new not_found_error_1.default();
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
headers: headers,
|
|
95
|
+
statusCode: 200,
|
|
96
|
+
body: '{}',
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
LambdaApiProxyHandler.prototype.findRoute = function (event) {
|
|
100
|
+
return this.routes.find(function (_a) {
|
|
101
|
+
var path = _a.path, method = _a.method;
|
|
102
|
+
var matches = (0, node_match_path_1.match)(path, event.path).matches;
|
|
103
|
+
return matches && (0, compare_ignore_case_1.default)(method, event.httpMethod);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
LambdaApiProxyHandler.prototype.handler = function (event, context) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var activeContext;
|
|
109
|
+
var _this = this;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
(0, check_envs_1.default)(fintalk_logger_1.default);
|
|
112
|
+
activeContext = api_1.propagation.extract(api_1.context.active(), {
|
|
113
|
+
traceparent: event.headers.traceparent,
|
|
114
|
+
});
|
|
115
|
+
return [2, otlp_1.tracer.startActiveSpan('handler', {
|
|
116
|
+
kind: api_1.SpanKind.SERVER,
|
|
117
|
+
startTime: (0, core_1.hrTime)(),
|
|
118
|
+
}, activeContext, function (span) { return __awaiter(_this, void 0, void 0, function () {
|
|
119
|
+
var remainingTimeInMillis, timeout, spanContext, request, method, route, _a, response, error_1;
|
|
120
|
+
var _b;
|
|
121
|
+
var _c, _d, _e, _f, _g, _h, _j;
|
|
122
|
+
return __generator(this, function (_k) {
|
|
123
|
+
switch (_k.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
remainingTimeInMillis = context.getRemainingTimeInMillis();
|
|
126
|
+
timeout = setTimeout(function () {
|
|
127
|
+
span.setStatus({
|
|
128
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
129
|
+
message: 'Detected an impending timeout',
|
|
130
|
+
});
|
|
131
|
+
span.end((0, core_1.hrTime)());
|
|
132
|
+
(0, provider_flush_1.default)(otlp_1.tracerProvider);
|
|
133
|
+
}, remainingTimeInMillis - 100);
|
|
134
|
+
_k.label = 1;
|
|
135
|
+
case 1:
|
|
136
|
+
_k.trys.push([1, 5, 6, 8]);
|
|
137
|
+
spanContext = span.spanContext();
|
|
138
|
+
fintalk_logger_1.default.setCustomArgs({
|
|
139
|
+
dd: {
|
|
140
|
+
trace_id: spanContext.traceId,
|
|
141
|
+
span_id: spanContext.spanId,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
request = (0, parse_request_1.default)(event, context);
|
|
145
|
+
span.setAttributes((_b = {},
|
|
146
|
+
_b[semantic_conventions_1.SemanticResourceAttributes.CLOUD_REGION] = process.env.AWS_REGION,
|
|
147
|
+
_b[semantic_conventions_1.SemanticResourceAttributes.CLOUD_PLATFORM] = semantic_conventions_1.CloudPlatformValues.AWS_LAMBDA,
|
|
148
|
+
_b['faas.version'] = process.env.AWS_EXECUTION_ENV,
|
|
149
|
+
_b[semantic_conventions_1.SemanticAttributes.FAAS_EXECUTION] = request.id,
|
|
150
|
+
_b[semantic_conventions_1.SemanticResourceAttributes.FAAS_MAX_MEMORY] = process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE,
|
|
151
|
+
_b[semantic_conventions_1.SemanticResourceAttributes.FAAS_NAME] = context.functionName,
|
|
152
|
+
_b[semantic_conventions_1.SemanticResourceAttributes.FAAS_ID] = context.invokedFunctionArn,
|
|
153
|
+
_b[semantic_conventions_1.SemanticAttributes.FAAS_TRIGGER] = semantic_conventions_1.FaasTriggerValues.HTTP,
|
|
154
|
+
_b['client.address'] = request.ip,
|
|
155
|
+
_b['server.address'] = event.requestContext.domainName,
|
|
156
|
+
_b['server.port'] = '443',
|
|
157
|
+
_b['http.request.method'] = request.method,
|
|
158
|
+
_b['url.path'] = request.path,
|
|
159
|
+
_b['url.query'] = (0, convert_query_string_1.default)(request.multiValueQuery),
|
|
160
|
+
_b['url.scheme'] = 'https',
|
|
161
|
+
_b['user_agent.original'] = request.userAgent,
|
|
162
|
+
_b));
|
|
163
|
+
method = event.httpMethod.toUpperCase();
|
|
164
|
+
if (method === 'OPTIONS') {
|
|
165
|
+
return [2, this.corsObject(event, constants_1.defaultHeaders)];
|
|
166
|
+
}
|
|
167
|
+
route = this.findRoute(event);
|
|
168
|
+
if (!route) {
|
|
169
|
+
fintalk_logger_1.default.warn({
|
|
170
|
+
message: 'Route not found',
|
|
171
|
+
path: event.path,
|
|
172
|
+
method: method,
|
|
173
|
+
});
|
|
174
|
+
throw new not_found_error_1.default();
|
|
175
|
+
}
|
|
176
|
+
span.setAttribute('http.route', route.path);
|
|
177
|
+
request = (0, parse_request_1.default)(event, context, route.path);
|
|
178
|
+
if (!route.auth) return [3, 3];
|
|
179
|
+
_a = request;
|
|
180
|
+
return [4, route.auth(request)];
|
|
181
|
+
case 2:
|
|
182
|
+
_a.auth = _k.sent();
|
|
183
|
+
_k.label = 3;
|
|
184
|
+
case 3:
|
|
185
|
+
span.setAttributes({
|
|
186
|
+
user_id: (_c = request.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
187
|
+
email: (_d = request.user) === null || _d === void 0 ? void 0 : _d.email,
|
|
188
|
+
});
|
|
189
|
+
if (process.env.OTLP_LAMBDA_DEBUG === 'true') {
|
|
190
|
+
span.setAttributes({
|
|
191
|
+
'http.request.body': JSON.stringify(request.body),
|
|
192
|
+
'http.request.headers': JSON.stringify(request.headers),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return [4, route.run(request, context)];
|
|
196
|
+
case 4:
|
|
197
|
+
response = _k.sent();
|
|
198
|
+
span.setAttribute('http.response.status_code', (_f = (_e = response.statusCode) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : '200');
|
|
199
|
+
if (process.env.OTLP_LAMBDA_DEBUG === 'true') {
|
|
200
|
+
span.setAttributes({
|
|
201
|
+
'http.response.body': JSON.stringify(response.body),
|
|
202
|
+
'http.response.headers': JSON.stringify(response.headers),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
206
|
+
return [2, {
|
|
207
|
+
headers: __assign(__assign({}, constants_1.defaultHeaders), response.headers),
|
|
208
|
+
multiValueHeaders: response.multiValueHeaders,
|
|
209
|
+
statusCode: (_g = response.statusCode) !== null && _g !== void 0 ? _g : 200,
|
|
210
|
+
body: JSON.stringify(response.body),
|
|
211
|
+
}];
|
|
212
|
+
case 5:
|
|
213
|
+
error_1 = _k.sent();
|
|
214
|
+
span.setAttributes({
|
|
215
|
+
'exception.message': error_1.message,
|
|
216
|
+
'exception.stacktrace': error_1.trace,
|
|
217
|
+
'http.response.status_code': (_j = (_h = error_1.code) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : '500',
|
|
218
|
+
});
|
|
219
|
+
span.setStatus({
|
|
220
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
221
|
+
message: error_1.message,
|
|
222
|
+
});
|
|
223
|
+
if (error_1.isTreated) {
|
|
224
|
+
return [2, {
|
|
225
|
+
headers: constants_1.defaultHeaders,
|
|
226
|
+
statusCode: error_1.code,
|
|
227
|
+
body: JSON.stringify(error_1.toObject()),
|
|
228
|
+
}];
|
|
229
|
+
}
|
|
230
|
+
fintalk_logger_1.default.error(error_1);
|
|
231
|
+
return [2, {
|
|
232
|
+
headers: constants_1.defaultHeaders,
|
|
233
|
+
statusCode: 500,
|
|
234
|
+
body: JSON.stringify({
|
|
235
|
+
error: {
|
|
236
|
+
message: 'Internal Server Error',
|
|
237
|
+
},
|
|
238
|
+
}),
|
|
239
|
+
}];
|
|
240
|
+
case 6:
|
|
241
|
+
clearTimeout(timeout);
|
|
242
|
+
span.end((0, core_1.hrTime)());
|
|
243
|
+
return [4, (0, provider_flush_1.default)(otlp_1.tracerProvider)];
|
|
244
|
+
case 7:
|
|
245
|
+
_k.sent();
|
|
246
|
+
return [7];
|
|
247
|
+
case 8: return [2];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}); })];
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
return LambdaApiProxyHandler;
|
|
255
|
+
}());
|
|
256
|
+
exports.LambdaApiProxyHandler = LambdaApiProxyHandler;
|
|
257
|
+
//# sourceMappingURL=api-proxy.js.map
|