@felloh-org/lambda-wrapper 1.0.23 → 1.0.24
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.
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _typeorm = require("typeorm");
|
|
9
|
+
|
|
10
|
+
var _uuid = require("uuid");
|
|
11
|
+
|
|
12
|
+
var _organisation = _interopRequireDefault(require("../../user/organisation"));
|
|
13
|
+
|
|
14
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
19
|
+
|
|
20
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
21
|
+
|
|
22
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); }
|
|
23
|
+
|
|
24
|
+
let Token = (_dec = (0, _typeorm.Entity)({
|
|
25
|
+
name: 'token',
|
|
26
|
+
schema: 'token'
|
|
27
|
+
}), _dec2 = (0, _typeorm.PrimaryColumn)("varchar"), _dec3 = (0, _typeorm.ManyToOne)(() => _organisation.default), _dec4 = (0, _typeorm.JoinColumn)({
|
|
28
|
+
name: 'organisation_id',
|
|
29
|
+
referencedColumnName: 'id'
|
|
30
|
+
}), _dec5 = (0, _typeorm.Column)({
|
|
31
|
+
type: "varchar",
|
|
32
|
+
length: "250"
|
|
33
|
+
}), _dec6 = (0, _typeorm.Column)({
|
|
34
|
+
type: "varchar",
|
|
35
|
+
length: "150"
|
|
36
|
+
}), _dec7 = (0, _typeorm.Column)({
|
|
37
|
+
type: "varchar",
|
|
38
|
+
length: "150"
|
|
39
|
+
}), _dec8 = (0, _typeorm.Column)({
|
|
40
|
+
type: "varchar",
|
|
41
|
+
length: "4"
|
|
42
|
+
}), _dec9 = (0, _typeorm.CreateDateColumn)(), _dec(_class = (_class2 = class Token {
|
|
43
|
+
constructor() {
|
|
44
|
+
_initializerDefineProperty(this, "id", _descriptor, this);
|
|
45
|
+
|
|
46
|
+
_initializerDefineProperty(this, "organisation", _descriptor2, this);
|
|
47
|
+
|
|
48
|
+
_initializerDefineProperty(this, "name", _descriptor3, this);
|
|
49
|
+
|
|
50
|
+
_initializerDefineProperty(this, "public_key", _descriptor4, this);
|
|
51
|
+
|
|
52
|
+
_initializerDefineProperty(this, "secret_key", _descriptor5, this);
|
|
53
|
+
|
|
54
|
+
_initializerDefineProperty(this, "secret_key_last_four", _descriptor6, this);
|
|
55
|
+
|
|
56
|
+
_initializerDefineProperty(this, "created_at", _descriptor7, this);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "id", [_dec2], {
|
|
60
|
+
configurable: true,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
initializer: function () {
|
|
64
|
+
return (0, _uuid.v4)();
|
|
65
|
+
}
|
|
66
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "organisation", [_dec3, _dec4], {
|
|
67
|
+
configurable: true,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
initializer: function () {
|
|
71
|
+
return _organisation.default;
|
|
72
|
+
}
|
|
73
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "name", [_dec5], {
|
|
74
|
+
configurable: true,
|
|
75
|
+
enumerable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
initializer: function () {
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "public_key", [_dec6], {
|
|
81
|
+
configurable: true,
|
|
82
|
+
enumerable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
initializer: function () {
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "secret_key", [_dec7], {
|
|
88
|
+
configurable: true,
|
|
89
|
+
enumerable: true,
|
|
90
|
+
writable: true,
|
|
91
|
+
initializer: function () {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "secret_key_last_four", [_dec8], {
|
|
95
|
+
configurable: true,
|
|
96
|
+
enumerable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
initializer: function () {
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
101
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "created_at", [_dec9], {
|
|
102
|
+
configurable: true,
|
|
103
|
+
enumerable: true,
|
|
104
|
+
writable: true,
|
|
105
|
+
initializer: null
|
|
106
|
+
})), _class2)) || _class);
|
|
107
|
+
exports.default = Token;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { MigrationInterface, QueryRunner } = require("typeorm");
|
|
2
|
+
|
|
3
|
+
module.exports = class token1645613145774 {
|
|
4
|
+
name = 'token1645613145774'
|
|
5
|
+
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE TABLE "token"."token" ("id" character varying NOT NULL, "name" character varying(250) NOT NULL, "public_key" character varying(150) NOT NULL, "secret_key" character varying(150) NOT NULL, "secret_key_last_four" character varying(4) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "organisation_id" character varying(150), CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))`);
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "token"."token" ADD CONSTRAINT "FK_56e183ecf0324bbecebec1b4057" FOREIGN KEY ("organisation_id") REFERENCES "user"."organisation"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async down(queryRunner) {
|
|
12
|
+
await queryRunner.query(`ALTER TABLE "token"."token" DROP CONSTRAINT "FK_56e183ecf0324bbecebec1b4057"`);
|
|
13
|
+
await queryRunner.query(`DROP TABLE "token"."token"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/wrapper/index.js
CHANGED
|
@@ -34,7 +34,7 @@ const handleSuccess = (di, outcome) => {
|
|
|
34
34
|
} // Outcome may be undefined as not all lambdas have a return value.
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
logger.metric('lambda.
|
|
37
|
+
logger.metric('lambda.status_code', outcome && outcome.statusCode || 200);
|
|
38
38
|
return outcome;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
@@ -62,12 +62,10 @@ exports.handleSuccess = handleSuccess;
|
|
|
62
62
|
|
|
63
63
|
const handleError = (di, error, throwError = false) => {
|
|
64
64
|
const logger = di.get(_dependencies.DEFINITIONS.LOGGER);
|
|
65
|
-
logger.metric('lambda.
|
|
65
|
+
logger.metric('lambda.status_code', error.code || 500);
|
|
66
66
|
|
|
67
67
|
if (error.raiseOnEpsagon || !error.code || error.code >= 500) {
|
|
68
68
|
logger.error(error);
|
|
69
|
-
} else {
|
|
70
|
-
logger.info(error);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
if (throwError) {
|
|
@@ -118,7 +116,7 @@ const wrapper = (configuration, handler, throwError = false) => {
|
|
|
118
116
|
|
|
119
117
|
|
|
120
118
|
if (request.getIp() !== null) {
|
|
121
|
-
logger.metric('
|
|
119
|
+
logger.metric('ip_address', request.getIp(), true);
|
|
122
120
|
} // Add metrics with user browser information for rapid debugging
|
|
123
121
|
|
|
124
122
|
|