@saasquatch/program-boilerplate 3.6.1-2 → 3.6.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 +4 -3
- package/dist/jsonata.js +3 -4
- package/dist/trigger.js +0 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "triggerProgram", { enumerable: true, get: functi
|
|
|
37
37
|
const logger_1 = require("./logger");
|
|
38
38
|
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } });
|
|
39
39
|
Object.defineProperty(exports, "setLogLevel", { enumerable: true, get: function () { return logger_1.setLogLevel; } });
|
|
40
|
+
const logger_2 = require("@saasquatch/logger");
|
|
40
41
|
const types = __importStar(require("./types"));
|
|
41
42
|
exports.types = types;
|
|
42
43
|
const jsonata_1 = require("./jsonata");
|
|
@@ -50,7 +51,7 @@ Object.defineProperty(exports, "setRewardSchedule", { enumerable: true, get: fun
|
|
|
50
51
|
Object.defineProperty(exports, "numToEquality", { enumerable: true, get: function () { return utils_1.numToEquality; } });
|
|
51
52
|
Object.defineProperty(exports, "getTriggerSchema", { enumerable: true, get: function () { return utils_1.getTriggerSchema; } });
|
|
52
53
|
Object.defineProperty(exports, "getUserCustomFieldsFromJsonata", { enumerable: true, get: function () { return utils_1.getUserCustomFieldsFromJsonata; } });
|
|
53
|
-
const
|
|
54
|
+
const logger_3 = require("@saasquatch/logger");
|
|
54
55
|
/**
|
|
55
56
|
* Returns an express server that serves the provided handlers
|
|
56
57
|
* as a program
|
|
@@ -62,10 +63,10 @@ const logger_2 = require("@saasquatch/logger");
|
|
|
62
63
|
function webtask(program = {}) {
|
|
63
64
|
const compression = require("compression");
|
|
64
65
|
const app = express_1.default();
|
|
65
|
-
const logger =
|
|
66
|
+
const logger = logger_2.getLogger("program-boilerplate");
|
|
66
67
|
app.use(express_1.default.json({ limit: process.env.MAX_PAYLOAD_SIZE || "1mb" }));
|
|
67
68
|
app.use(compression());
|
|
68
|
-
app.use(
|
|
69
|
+
app.use(logger_3.httpLogMiddleware(logger));
|
|
69
70
|
// Enforce HTTPS. The server does not redirect http -> https
|
|
70
71
|
// because OWASP advises not to
|
|
71
72
|
app.use((req, res, next) => {
|
package/dist/jsonata.js
CHANGED
|
@@ -5,10 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.timeboxedJsonata = exports.safeJsonata = exports.timeboxExpression = void 0;
|
|
7
7
|
const jsonata_1 = __importDefault(require("jsonata"));
|
|
8
|
-
const logger_1 = require("
|
|
8
|
+
const logger_1 = require("@saasquatch/logger");
|
|
9
9
|
const TIMEOUT = 5000;
|
|
10
10
|
const MAXDEPTH = 1000;
|
|
11
|
-
const logger = logger_1.getLogger(process.env.PROGRAM_LOG_LEVEL || "debug");
|
|
12
11
|
/**
|
|
13
12
|
* Protect the process/browser from a runnaway expression
|
|
14
13
|
* i.e. Infinite loop (tail recursion), or excessive stack growth
|
|
@@ -61,7 +60,7 @@ function safeJsonata(expression, inputData) {
|
|
|
61
60
|
return jsonataQuery.evaluate(inputData);
|
|
62
61
|
}
|
|
63
62
|
catch (e) {
|
|
64
|
-
|
|
63
|
+
logger_1.getLogger("program-boilerplate").warn(`Failed to evaluate JSONata expression: ${e.message}`);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
exports.safeJsonata = safeJsonata;
|
|
@@ -74,7 +73,7 @@ function timeboxedJsonata(expression, inputData, timeout, maxDepth) {
|
|
|
74
73
|
}
|
|
75
74
|
catch (e) {
|
|
76
75
|
if (e instanceof Error) {
|
|
77
|
-
|
|
76
|
+
logger_1.getLogger("program-boilerplate").warn(`Failed to evaluate JSONata expression: ${e.message}`);
|
|
78
77
|
}
|
|
79
78
|
return { success: false, result: undefined };
|
|
80
79
|
}
|
package/dist/trigger.js
CHANGED
|
@@ -191,12 +191,6 @@ function handleProgramVariableSchemaRequest(body, program) {
|
|
|
191
191
|
["error.message"]: e.message,
|
|
192
192
|
["error.stack"]: e.stack,
|
|
193
193
|
});
|
|
194
|
-
// FIXME: This code wasn't actually returning a 500 before this, was that meant to be the case
|
|
195
|
-
// or did we just forget?
|
|
196
|
-
return {
|
|
197
|
-
json: errorMes,
|
|
198
|
-
code: 500,
|
|
199
|
-
};
|
|
200
194
|
}
|
|
201
195
|
if (!newSchema) {
|
|
202
196
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasquatch/program-boilerplate",
|
|
3
|
-
"version": "3.6.1
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "Boilerplate for writing programs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"prepush": "npm run format",
|
|
14
14
|
"prepare": "npm run build",
|
|
15
15
|
"deploy": "np",
|
|
16
|
-
"test": "jest"
|
|
16
|
+
"test": "SSQT_LOG_LEVEL=emerg jest"
|
|
17
17
|
},
|
|
18
18
|
"author": "",
|
|
19
19
|
"license": "ISC",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@saasquatch/jsonata-paths-extractor": "^1.0.1",
|
|
36
|
-
"@saasquatch/logger": "^1.0.0
|
|
36
|
+
"@saasquatch/logger": "^1.0.0",
|
|
37
37
|
"bson-objectid": "^1.3.1",
|
|
38
38
|
"compression": "^1.7.4",
|
|
39
39
|
"express": "^4.17.1",
|