fintalk-pkg 2.3.14 → 2.3.15
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/base/FlowControl.js +7 -125
- package/package.json +3 -2
package/base/FlowControl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const logger = require("
|
|
1
|
+
const logger = require("ton-logger")
|
|
2
2
|
|
|
3
3
|
let controller = null;
|
|
4
4
|
|
|
@@ -65,133 +65,15 @@ module.exports.redirect = (url) => {
|
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
function logLambda(statusCode, resBody,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var userAgent = "";
|
|
75
|
-
var consumerIp = "";
|
|
76
|
-
|
|
77
|
-
if(controller.event != null && controller.event.headers != null) {
|
|
78
|
-
userAgent = controller.event.headers["User-Agent"] != null ? controller.event.headers["User-Agent"] : "";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if(controller.event != null && controller.event.requestContext != null && controller.event.requestContext.identity != null && controller.event.requestContext.identity.sourceIp != null) {
|
|
82
|
-
consumerIp = controller.event.requestContext.identity.sourceIp;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let resLength = 0;
|
|
86
|
-
if(resBody != null) {
|
|
87
|
-
if(typeof resBody !== "string") {
|
|
88
|
-
resBody = JSON.stringify(resBody, Object.getOwnPropertyNames(resBody));
|
|
89
|
-
}
|
|
90
|
-
resLength = Buffer.byteLength(resBody);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if(resBody == null || (statusCode == 200 && !forceBody)) {
|
|
94
|
-
resBody = {};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let logObj = {
|
|
98
|
-
httpLog : controller.http,
|
|
99
|
-
date : start,
|
|
100
|
-
duration : new Date - start,
|
|
101
|
-
method : method,
|
|
102
|
-
statusCode : statusCode,
|
|
103
|
-
path : controller.event.path != null ? controller.event.path : "",
|
|
104
|
-
resBody : resBody,
|
|
105
|
-
resLength : resLength,
|
|
106
|
-
query : controller.event.queryStringParameters != null ? controller.event.queryStringParameters : {},
|
|
107
|
-
body : controller.event.body != null ? controller.event.body : {},
|
|
108
|
-
header: controller.event.headers != null ? controller.event.headers : {},
|
|
109
|
-
userAgent: userAgent,
|
|
110
|
-
consumerIp : consumerIp,
|
|
111
|
-
sendToDataLake : true
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
if(controller.warmup) {
|
|
115
|
-
logObj.warmup = controller.warmup;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if(controller.coldStart) {
|
|
119
|
-
logObj.coldStart = controller.coldStart;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
logger.log(JSON.stringify(logObj), true, false);
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
68
|
+
function logLambda(statusCode, resBody, _) {
|
|
69
|
+
logger.info({
|
|
70
|
+
message: 'Lambda response',
|
|
71
|
+
statusCode,
|
|
72
|
+
response: resBody
|
|
73
|
+
})
|
|
126
74
|
}
|
|
127
75
|
|
|
128
76
|
module.exports.setEnvVariables = async function(names, paths) {
|
|
129
|
-
// const { SSM } = require("@aws-sdk/client-ssm-node");
|
|
130
|
-
// const ssm = new SSM({ region: "us-east-1" });
|
|
131
|
-
|
|
132
|
-
// let namesToQuery = [];
|
|
133
|
-
// let query = [];
|
|
134
|
-
// let request;
|
|
135
|
-
// let values;
|
|
136
|
-
|
|
137
|
-
// if (names != null) {
|
|
138
|
-
|
|
139
|
-
// var cache = false;
|
|
140
|
-
|
|
141
|
-
// Object.keys(names).forEach(function (item) {
|
|
142
|
-
// if (process.env[item]) {
|
|
143
|
-
// cache = true;
|
|
144
|
-
// }
|
|
145
|
-
// namesToQuery.push(names[item]);
|
|
146
|
-
// });
|
|
147
|
-
|
|
148
|
-
// if (cache)
|
|
149
|
-
// return;
|
|
150
|
-
|
|
151
|
-
// let query = {
|
|
152
|
-
// "Names": namesToQuery,
|
|
153
|
-
// "WithDecryption": false,
|
|
154
|
-
// };
|
|
155
|
-
|
|
156
|
-
// let request = await ssm.getParameters(query);
|
|
157
|
-
// let values = request.Parameters;
|
|
158
|
-
|
|
159
|
-
// for (let i = 0; i < values.length; i++) {
|
|
160
|
-
// const element = values[i];
|
|
161
|
-
|
|
162
|
-
// for (let j = 0; j < Object.keys(names).length; j++) {
|
|
163
|
-
// const iName = Object.keys(names)[j];
|
|
164
|
-
// if(names[iName] == element.Name) {
|
|
165
|
-
// process.env[iName] = element.Value;
|
|
166
|
-
// break;
|
|
167
|
-
// }
|
|
168
|
-
|
|
169
|
-
// }
|
|
170
|
-
|
|
171
|
-
// }
|
|
172
|
-
// }
|
|
173
|
-
|
|
174
|
-
// if (paths != null) {
|
|
175
|
-
// for (let i = 0; i < Object.keys(paths).length; i++) {
|
|
176
|
-
// const path = Object.keys(paths)[i];
|
|
177
|
-
|
|
178
|
-
// //TEF_MUNDIPAGG-PK
|
|
179
|
-
// query = {
|
|
180
|
-
// "Path": paths[path],
|
|
181
|
-
// "WithDecryption": false,
|
|
182
|
-
// };
|
|
183
|
-
|
|
184
|
-
// request = await ssm.getParametersByPath(query).promise();
|
|
185
|
-
// values = request.Parameters;
|
|
186
|
-
|
|
187
|
-
// for (let j = 0; j < values.length; j++) {
|
|
188
|
-
// const element = values[j];
|
|
189
|
-
// const name = path + "_" + element.Name.substring(element.Name.lastIndexOf("/") + 1, element.Name.length).toUpperCase();
|
|
190
|
-
// process.env[name] = element.Value;
|
|
191
|
-
// }
|
|
192
|
-
|
|
193
|
-
// }
|
|
194
|
-
// }
|
|
195
77
|
|
|
196
78
|
}
|
|
197
79
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fintalk-pkg",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.15",
|
|
4
4
|
"description": "Common code between projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"dotenv": "^6.2.0",
|
|
28
|
-
"dynamoose": "^2.3.0"
|
|
28
|
+
"dynamoose": "^2.3.0",
|
|
29
|
+
"ton-logger": "~1.1.2"
|
|
29
30
|
},
|
|
30
31
|
"pre-commit": {
|
|
31
32
|
"run": [
|