kayvee 3.18.0 → 4.0.0
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 +147 -202
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/kayvee.d.ts +12 -0
- package/dist/kayvee.d.ts.map +1 -0
- package/{build/lib → dist}/kayvee.js +17 -30
- package/dist/logger/logger.d.ts +49 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/{build/lib → dist}/logger/logger.js +91 -83
- package/dist/middleware.d.ts +23 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +196 -0
- package/dist/package.json +89 -0
- package/dist/router/index.d.ts +23 -0
- package/dist/router/index.d.ts.map +1 -0
- package/{build/lib → dist}/router/index.js +33 -45
- package/package.json +63 -27
- package/.circleci/config.yml +0 -25
- package/.eslintrc.js +0 -124
- package/.github/workflows/notify-ci-status.yml +0 -20
- package/.nvmrc +0 -1
- package/.prettierrc.json +0 -1
- package/Makefile +0 -55
- package/benchmarks/data/.keep +0 -1
- package/benchmarks/data/corpus-basic.json +0 -22
- package/benchmarks/data/corpus-pathological.json +0 -22
- package/benchmarks/data/corpus-realistic.json +0 -22
- package/benchmarks/data/kvconfig-basic.yml +0 -7
- package/benchmarks/data/kvconfig-pathological.yml +0 -222
- package/benchmarks/data/kvconfig-realistic.yml +0 -39
- package/benchmarks/routing.js +0 -116
- package/build/lib/logger/helpers.js +0 -0
- package/build/lib/middleware.js +0 -274
- package/build/package.json +0 -53
- package/build/test/context_logger.js +0 -69
- package/build/test/kayvee.js +0 -36
- package/build/test/logger_test.js +0 -345
- package/build/test/middleware.js +0 -556
- package/build/test/router.js +0 -451
- package/index.js +0 -7
- package/lib/kayvee.ts +0 -73
- package/lib/logger/helpers.ts +0 -0
- package/lib/logger/logger.ts +0 -312
- package/lib/middleware.ts +0 -317
- package/lib/router/index.ts +0 -234
- package/lib/router/schema_definitions.json +0 -158
- package/test/context_logger.ts +0 -76
- package/test/kayvee.ts +0 -50
- package/test/kvconfig.yml +0 -14
- package/test/logger_test.ts +0 -378
- package/test/middleware.ts +0 -632
- package/test/router.ts +0 -558
- package/test/static/empty.css +0 -0
- package/test/static/js/empty.js +0 -0
- package/test/tests.json +0 -100
- package/tsconfig.json +0 -10
- /package/{build/lib → dist}/router/schema_definitions.json +0 -0
package/build/test/router.js
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
var assert = require("assert");
|
|
2
|
-
var router = require("../lib/router");
|
|
3
|
-
describe("router.Router", () => {
|
|
4
|
-
describe("constructor", () => {
|
|
5
|
-
it("parses well formatted configs", () => {
|
|
6
|
-
process.env.SCHOOL = "Hogwarts";
|
|
7
|
-
const conf = `
|
|
8
|
-
routes:
|
|
9
|
-
rule-one:
|
|
10
|
-
matchers:
|
|
11
|
-
title: ["authorize-app"]
|
|
12
|
-
output:
|
|
13
|
-
type: "notifications"
|
|
14
|
-
channel: "%{foo.bar}"
|
|
15
|
-
icon: ":rocket:"
|
|
16
|
-
message: "authorized %{foo.bar} in \${SCHOOL}"
|
|
17
|
-
user: "@fishman"
|
|
18
|
-
rule-two:
|
|
19
|
-
matchers:
|
|
20
|
-
foo.bar: ["multiple", "matches"]
|
|
21
|
-
baz: ["whatever"]
|
|
22
|
-
output:
|
|
23
|
-
type: "alerts"
|
|
24
|
-
series: "other-series"
|
|
25
|
-
dimensions: ["baz"]
|
|
26
|
-
stat_type: "gauge"
|
|
27
|
-
rule-three:
|
|
28
|
-
matchers:
|
|
29
|
-
foo.bar: ["multiple", "matches"]
|
|
30
|
-
baz: ["whatever"]
|
|
31
|
-
output:
|
|
32
|
-
type: "alerts"
|
|
33
|
-
series: "other-series"
|
|
34
|
-
dimensions: ["baz"]
|
|
35
|
-
stat_type: "gauge"
|
|
36
|
-
value_field: "hello"
|
|
37
|
-
rule-four:
|
|
38
|
-
matchers:
|
|
39
|
-
foo.bar: ["multiple", "matches"]
|
|
40
|
-
baz: ["whatever"]
|
|
41
|
-
output:
|
|
42
|
-
type: "alerts"
|
|
43
|
-
series: "other-series"
|
|
44
|
-
dimensions: []
|
|
45
|
-
stat_type: "gauge"
|
|
46
|
-
rule-five:
|
|
47
|
-
matchers:
|
|
48
|
-
foo.bar: [true]
|
|
49
|
-
baz: [false]
|
|
50
|
-
output:
|
|
51
|
-
type: "alerts"
|
|
52
|
-
series: "other-series"
|
|
53
|
-
dimensions: []
|
|
54
|
-
stat_type: "gauge"
|
|
55
|
-
`;
|
|
56
|
-
const expected = [
|
|
57
|
-
new router.Rule("rule-one", { title: ["authorize-app"] }, {
|
|
58
|
-
type: "notifications",
|
|
59
|
-
channel: "%{foo.bar}",
|
|
60
|
-
icon: ":rocket:",
|
|
61
|
-
message: "authorized %{foo.bar} in Hogwarts",
|
|
62
|
-
user: "@fishman",
|
|
63
|
-
}),
|
|
64
|
-
new router.Rule("rule-two", { "foo.bar": ["multiple", "matches"], baz: ["whatever"] }, {
|
|
65
|
-
type: "alerts",
|
|
66
|
-
series: "other-series",
|
|
67
|
-
dimensions: ["baz"],
|
|
68
|
-
stat_type: "gauge",
|
|
69
|
-
value_field: "value",
|
|
70
|
-
}),
|
|
71
|
-
new router.Rule("rule-three", { "foo.bar": ["multiple", "matches"], baz: ["whatever"] }, {
|
|
72
|
-
type: "alerts",
|
|
73
|
-
series: "other-series",
|
|
74
|
-
dimensions: ["baz"],
|
|
75
|
-
stat_type: "gauge",
|
|
76
|
-
value_field: "hello",
|
|
77
|
-
}),
|
|
78
|
-
new router.Rule("rule-four", { "foo.bar": ["multiple", "matches"], baz: ["whatever"] }, {
|
|
79
|
-
type: "alerts",
|
|
80
|
-
series: "other-series",
|
|
81
|
-
dimensions: [],
|
|
82
|
-
stat_type: "gauge",
|
|
83
|
-
value_field: "value",
|
|
84
|
-
}),
|
|
85
|
-
new router.Rule("rule-five", { "foo.bar": [true], baz: [false] }, {
|
|
86
|
-
type: "alerts",
|
|
87
|
-
series: "other-series",
|
|
88
|
-
dimensions: [],
|
|
89
|
-
stat_type: "gauge",
|
|
90
|
-
value_field: "value",
|
|
91
|
-
}),
|
|
92
|
-
];
|
|
93
|
-
const actual = new router.Router();
|
|
94
|
-
actual._loadConfigString(conf);
|
|
95
|
-
assert.deepEqual(actual.rules, expected);
|
|
96
|
-
});
|
|
97
|
-
it("rejects specials in matchers", () => {
|
|
98
|
-
const confTmpl = (v) => `
|
|
99
|
-
routes:
|
|
100
|
-
non-string-values:
|
|
101
|
-
matchers:
|
|
102
|
-
no-numbers: [${v}]
|
|
103
|
-
output:
|
|
104
|
-
type: "analytics"
|
|
105
|
-
series: "fun"
|
|
106
|
-
`;
|
|
107
|
-
// Make sure the template works
|
|
108
|
-
const conf = confTmpl('"valid"');
|
|
109
|
-
const actual = new router.Router();
|
|
110
|
-
assert.doesNotThrow(() => actual._loadConfigString(conf));
|
|
111
|
-
for (const invalidVal of ["5", "[]", "{}"]) {
|
|
112
|
-
const invalidConf = confTmpl(invalidVal);
|
|
113
|
-
assert.throws(() => actual._loadConfigString(invalidConf));
|
|
114
|
-
}
|
|
115
|
-
assert.throws(() => actual._loadConfigString(confTmpl('""')));
|
|
116
|
-
return;
|
|
117
|
-
});
|
|
118
|
-
it("rejects duplicates in matchers", () => {
|
|
119
|
-
const confTmpl = (v) => `
|
|
120
|
-
routes:
|
|
121
|
-
sloppy:
|
|
122
|
-
matchers:
|
|
123
|
-
title: [${v}]
|
|
124
|
-
output:
|
|
125
|
-
type: "analytics"
|
|
126
|
-
series: "fun"
|
|
127
|
-
`;
|
|
128
|
-
const actual = new router.Router();
|
|
129
|
-
const validConf = confTmpl('"non-repeated", "name"');
|
|
130
|
-
assert.doesNotThrow(() => actual._loadConfigString(validConf));
|
|
131
|
-
const invalidConf = confTmpl('"repeated", "repeated", "name"');
|
|
132
|
-
assert.throws(() => actual._loadConfigString(invalidConf));
|
|
133
|
-
});
|
|
134
|
-
it("requires correct types in outputs", () => {
|
|
135
|
-
const confTmpl = (series, dimensions) => `
|
|
136
|
-
routes:
|
|
137
|
-
wrong:
|
|
138
|
-
matchers:
|
|
139
|
-
title: ["test"]
|
|
140
|
-
output:
|
|
141
|
-
type: "alerts"
|
|
142
|
-
series: ${series}
|
|
143
|
-
dimensions: ${dimensions}
|
|
144
|
-
value_field: "hihi"
|
|
145
|
-
stat_type: "gauge"
|
|
146
|
-
`;
|
|
147
|
-
const actual = new router.Router();
|
|
148
|
-
const validConf = confTmpl('"my-series"', '["dim1", "dim2"]');
|
|
149
|
-
assert.doesNotThrow(() => actual._loadConfigString(validConf));
|
|
150
|
-
const invalidConf0 = confTmpl('["my-series"]', '["dim1", "dim2"]');
|
|
151
|
-
assert.throws(() => actual._loadConfigString(invalidConf0));
|
|
152
|
-
const invalidConf1 = confTmpl('"my-series"', '"dim1"');
|
|
153
|
-
assert.throws(() => actual._loadConfigString(invalidConf1));
|
|
154
|
-
});
|
|
155
|
-
it("requires all keys in outputs", () => {
|
|
156
|
-
const confTmpl = (v) => `
|
|
157
|
-
routes:
|
|
158
|
-
wrong:
|
|
159
|
-
matchers:
|
|
160
|
-
title: ["test"]
|
|
161
|
-
output:
|
|
162
|
-
type: "alerts"${v}
|
|
163
|
-
dimensions: ["dim1", "dim2"]
|
|
164
|
-
stat_type: "gauge"
|
|
165
|
-
`;
|
|
166
|
-
const actual = new router.Router();
|
|
167
|
-
const validConf = confTmpl(`
|
|
168
|
-
series: "whatever"`);
|
|
169
|
-
assert.doesNotThrow(() => actual._loadConfigString(validConf));
|
|
170
|
-
const invalidConf = confTmpl("");
|
|
171
|
-
assert.throws(() => actual._loadConfigString(invalidConf));
|
|
172
|
-
});
|
|
173
|
-
it("doesn't allow extra keys", () => {
|
|
174
|
-
const confTmpl = (v) => `
|
|
175
|
-
routes:
|
|
176
|
-
wrong:
|
|
177
|
-
matchers:
|
|
178
|
-
title: ["test"]
|
|
179
|
-
output:
|
|
180
|
-
type: "metrics"${v}
|
|
181
|
-
dimensions: ["dim1", "dim2"]
|
|
182
|
-
`;
|
|
183
|
-
const actual = new router.Router();
|
|
184
|
-
const validConf = confTmpl(`
|
|
185
|
-
series: "whatever"`);
|
|
186
|
-
assert.doesNotThrow(() => actual._loadConfigString(validConf));
|
|
187
|
-
const invalidConf = confTmpl(`
|
|
188
|
-
series: "whatever"
|
|
189
|
-
something-else: "hi there"`);
|
|
190
|
-
assert.throws(() => actual._loadConfigString(invalidConf));
|
|
191
|
-
});
|
|
192
|
-
it("errors on type-os", () => {
|
|
193
|
-
const actual = new router.Router();
|
|
194
|
-
let config;
|
|
195
|
-
config = `
|
|
196
|
-
route: # Should be routes (plural)
|
|
197
|
-
string-values:
|
|
198
|
-
matchers:
|
|
199
|
-
errors: [ "type-o" ]
|
|
200
|
-
output:
|
|
201
|
-
type: "analytics"
|
|
202
|
-
series: "fun"
|
|
203
|
-
`;
|
|
204
|
-
assert.throws(() => actual._loadConfigString(config));
|
|
205
|
-
config = `
|
|
206
|
-
routes:
|
|
207
|
-
string-values:
|
|
208
|
-
matcher: # Should be matchers (plural)
|
|
209
|
-
errors: [ "type-o" ]
|
|
210
|
-
output:
|
|
211
|
-
type: "analytics"
|
|
212
|
-
series: "fun"
|
|
213
|
-
`;
|
|
214
|
-
assert.throws(() => actual._loadConfigString(config));
|
|
215
|
-
config = `
|
|
216
|
-
routes:
|
|
217
|
-
string-values:
|
|
218
|
-
matchers:
|
|
219
|
-
errors: [ "type-o" ]
|
|
220
|
-
outputs: # Should be output (signular)
|
|
221
|
-
type: "analytics"
|
|
222
|
-
series: "fun"
|
|
223
|
-
`;
|
|
224
|
-
assert.throws(() => actual._loadConfigString(config));
|
|
225
|
-
config = `
|
|
226
|
-
routes:
|
|
227
|
-
$invalid-string-values: # Invalid rule name
|
|
228
|
-
matchers:
|
|
229
|
-
errors: [ "type-o" ]
|
|
230
|
-
output:
|
|
231
|
-
type: "analytics"
|
|
232
|
-
series: "fun"
|
|
233
|
-
`;
|
|
234
|
-
assert.throws(() => actual._loadConfigString(config));
|
|
235
|
-
config = `
|
|
236
|
-
routes:
|
|
237
|
-
string-values:
|
|
238
|
-
matchers:
|
|
239
|
-
errors: [ "type-o" ]
|
|
240
|
-
output:
|
|
241
|
-
type: "analytic" # Should be analytics (plural)p
|
|
242
|
-
series: "fun"
|
|
243
|
-
`;
|
|
244
|
-
assert.throws(() => actual._loadConfigString(config));
|
|
245
|
-
config = `
|
|
246
|
-
routes:
|
|
247
|
-
string-values:
|
|
248
|
-
matchers:
|
|
249
|
-
errors: [ "*", "type-o" ] # A wildcard cannot exist with other matchers
|
|
250
|
-
output:
|
|
251
|
-
type: "analytics"
|
|
252
|
-
series: "fun"
|
|
253
|
-
`;
|
|
254
|
-
assert.throws(() => actual._loadConfigString(config));
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
describe("route", () => {
|
|
258
|
-
it("matches one or more rule and returns appropriate outputs", () => {
|
|
259
|
-
const r = new router.Router([
|
|
260
|
-
new router.Rule("rule-one", { title: ["hello", "hi"], foo: ["bar", "baz"] }, { channel: "#-%{foo}-", dimensions: ["-%{foo}-"] }),
|
|
261
|
-
new router.Rule("rule-two", { "bing.bong": ["buzz"] }, { series: "x" }),
|
|
262
|
-
]);
|
|
263
|
-
const msg0 = {
|
|
264
|
-
title: "hi",
|
|
265
|
-
foo: "bar",
|
|
266
|
-
};
|
|
267
|
-
const expected0 = [
|
|
268
|
-
{
|
|
269
|
-
rule: "rule-one",
|
|
270
|
-
channel: "#-bar-",
|
|
271
|
-
dimensions: ["-bar-"],
|
|
272
|
-
},
|
|
273
|
-
];
|
|
274
|
-
const actual0 = r.route(msg0).routes;
|
|
275
|
-
assert.deepEqual(expected0, actual0);
|
|
276
|
-
const msg1 = {
|
|
277
|
-
title: "hi",
|
|
278
|
-
bing: {
|
|
279
|
-
bong: "buzz",
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
const expected1 = [
|
|
283
|
-
{
|
|
284
|
-
rule: "rule-two",
|
|
285
|
-
series: "x",
|
|
286
|
-
},
|
|
287
|
-
];
|
|
288
|
-
const actual1 = r.route(msg1).routes;
|
|
289
|
-
assert.deepEqual(expected1, actual1);
|
|
290
|
-
const msg2 = {
|
|
291
|
-
title: "hello",
|
|
292
|
-
foo: "baz",
|
|
293
|
-
bing: {
|
|
294
|
-
bong: "buzz",
|
|
295
|
-
},
|
|
296
|
-
};
|
|
297
|
-
const expected2 = [
|
|
298
|
-
{
|
|
299
|
-
rule: "rule-one",
|
|
300
|
-
channel: "#-baz-",
|
|
301
|
-
dimensions: ["-baz-"],
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
rule: "rule-two",
|
|
305
|
-
series: "x",
|
|
306
|
-
},
|
|
307
|
-
];
|
|
308
|
-
const actual2 = r.route(msg2).routes;
|
|
309
|
-
assert.deepEqual(expected2, actual2);
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
describe("router.Rule", () => {
|
|
314
|
-
describe("matches", () => {
|
|
315
|
-
it("works on simple cases", () => {
|
|
316
|
-
const r = new router.Rule("test-rule", { title: ["hello", "hi"], foo: ["bar"] }, {});
|
|
317
|
-
assert(r.matches({
|
|
318
|
-
title: "hello",
|
|
319
|
-
foo: "bar",
|
|
320
|
-
}));
|
|
321
|
-
assert(r.matches({
|
|
322
|
-
title: "hi",
|
|
323
|
-
foo: "bar",
|
|
324
|
-
}));
|
|
325
|
-
assert(!r.matches({
|
|
326
|
-
title: "hi",
|
|
327
|
-
foo: "fighters",
|
|
328
|
-
}));
|
|
329
|
-
assert(!r.matches({
|
|
330
|
-
title: "howdy",
|
|
331
|
-
foo: "bar",
|
|
332
|
-
}));
|
|
333
|
-
assert(!r.matches({
|
|
334
|
-
"missing-stuff": "indeed",
|
|
335
|
-
}));
|
|
336
|
-
});
|
|
337
|
-
it("works on nested messages", () => {
|
|
338
|
-
const r = new router.Rule("test-rule", { "foo.bar": ["hello", "hi"] }, {});
|
|
339
|
-
assert(r.matches({
|
|
340
|
-
title: "greeting",
|
|
341
|
-
foo: {
|
|
342
|
-
bar: "hello",
|
|
343
|
-
},
|
|
344
|
-
}));
|
|
345
|
-
assert(r.matches({
|
|
346
|
-
title: "greeting",
|
|
347
|
-
foo: {
|
|
348
|
-
bar: "hi",
|
|
349
|
-
},
|
|
350
|
-
}));
|
|
351
|
-
assert(!r.matches({
|
|
352
|
-
title: "greeting",
|
|
353
|
-
foo: {
|
|
354
|
-
bar: "howdy",
|
|
355
|
-
},
|
|
356
|
-
}));
|
|
357
|
-
assert(!r.matches({
|
|
358
|
-
title: "greeting",
|
|
359
|
-
foo: {
|
|
360
|
-
baz: "howdy",
|
|
361
|
-
},
|
|
362
|
-
}));
|
|
363
|
-
assert(!r.matches({
|
|
364
|
-
title: "greeting",
|
|
365
|
-
boo: {
|
|
366
|
-
bar: "howdy",
|
|
367
|
-
},
|
|
368
|
-
}));
|
|
369
|
-
assert(!r.matches({
|
|
370
|
-
title: "greeting",
|
|
371
|
-
foo: "hi",
|
|
372
|
-
}));
|
|
373
|
-
});
|
|
374
|
-
it("wild card matching", () => {
|
|
375
|
-
const r = new router.Rule("test-rule", { any: ["*"] }, {});
|
|
376
|
-
assert(r.matches({
|
|
377
|
-
any: false,
|
|
378
|
-
}));
|
|
379
|
-
assert(r.matches({
|
|
380
|
-
any: 5,
|
|
381
|
-
}));
|
|
382
|
-
assert(r.matches({
|
|
383
|
-
any: "hello",
|
|
384
|
-
}));
|
|
385
|
-
assert(r.matches({
|
|
386
|
-
any: {
|
|
387
|
-
bar: "hi",
|
|
388
|
-
},
|
|
389
|
-
}));
|
|
390
|
-
assert(!r.matches({
|
|
391
|
-
any: "",
|
|
392
|
-
}));
|
|
393
|
-
assert(!r.matches({
|
|
394
|
-
any: null,
|
|
395
|
-
}));
|
|
396
|
-
assert(!r.matches({
|
|
397
|
-
any: undefined,
|
|
398
|
-
}));
|
|
399
|
-
assert(!r.matches({
|
|
400
|
-
title: "greeting",
|
|
401
|
-
foo: {
|
|
402
|
-
bar: "howdy",
|
|
403
|
-
},
|
|
404
|
-
}));
|
|
405
|
-
});
|
|
406
|
-
it("bool matching", () => {
|
|
407
|
-
const r = new router.Rule("test-rule", { bull: [true] }, {});
|
|
408
|
-
assert(r.matches({
|
|
409
|
-
bull: true,
|
|
410
|
-
}));
|
|
411
|
-
assert(r.matches({
|
|
412
|
-
any: false,
|
|
413
|
-
bull: true,
|
|
414
|
-
}));
|
|
415
|
-
assert(!r.matches({
|
|
416
|
-
bull: false,
|
|
417
|
-
}));
|
|
418
|
-
assert(!r.matches({
|
|
419
|
-
bull: "false",
|
|
420
|
-
}));
|
|
421
|
-
assert(!r.matches({
|
|
422
|
-
title: "greeting",
|
|
423
|
-
foo: {
|
|
424
|
-
bar: "howdy",
|
|
425
|
-
},
|
|
426
|
-
}));
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
describe("outputFor", () => {
|
|
430
|
-
it("substitutes kv entries", () => {
|
|
431
|
-
const r = new router.Rule("myrule", {}, {
|
|
432
|
-
channel: "#-%{foo}-",
|
|
433
|
-
dimensions: ["-%{foo}-", "-%{bar.baz}-"],
|
|
434
|
-
});
|
|
435
|
-
const msg = {
|
|
436
|
-
title: "greeting",
|
|
437
|
-
foo: "partner",
|
|
438
|
-
bar: {
|
|
439
|
-
baz: "nest egg",
|
|
440
|
-
},
|
|
441
|
-
};
|
|
442
|
-
const expected = {
|
|
443
|
-
rule: "myrule",
|
|
444
|
-
channel: "#-partner-",
|
|
445
|
-
dimensions: ["-partner-", "-nest egg-"],
|
|
446
|
-
};
|
|
447
|
-
const actual = r.outputFor(msg);
|
|
448
|
-
assert.deepEqual(expected, actual);
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
});
|
package/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
module.exports = require("./build/lib/kayvee");
|
|
2
|
-
// export logger capitalized to fix lint errors, lowercased to support legacy usage
|
|
3
|
-
module.exports.logger = module.exports.Logger = require("./build/lib/logger/logger");
|
|
4
|
-
module.exports.router = require("./build/lib/router");
|
|
5
|
-
module.exports.middleware = require("./build/lib/middleware");
|
|
6
|
-
module.exports.setGlobalRouting = module.exports.logger.setGlobalRouting;
|
|
7
|
-
module.exports.mockRouting = module.exports.logger.mockRouting;
|
package/lib/kayvee.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var _ = require("underscore");
|
|
2
|
-
|
|
3
|
-
const deploy_env = process.env._DEPLOY_ENV;
|
|
4
|
-
const workflow_id = process.env._EXECUTION_NAME;
|
|
5
|
-
const pod_id = process.env._POD_ID;
|
|
6
|
-
const pod_shortname = process.env._POD_SHORTNAME;
|
|
7
|
-
const pod_region = process.env._POD_REGION;
|
|
8
|
-
const pod_account = process.env._POD_ACCOUNT;
|
|
9
|
-
|
|
10
|
-
// Encode errors to strings instead of toJSON()
|
|
11
|
-
function replaceErrors(key, value) {
|
|
12
|
-
if (value instanceof Error) {
|
|
13
|
-
return value.toString();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Converts a map to a string space-delimited key=val pairs
|
|
20
|
-
function format(data) {
|
|
21
|
-
if (deploy_env || workflow_id || pod_id || pod_shortname || pod_account || pod_region) {
|
|
22
|
-
const extras: any = {};
|
|
23
|
-
if (deploy_env) {
|
|
24
|
-
extras.deploy_env = deploy_env;
|
|
25
|
-
}
|
|
26
|
-
if (workflow_id) {
|
|
27
|
-
extras.wf_id = workflow_id;
|
|
28
|
-
}
|
|
29
|
-
if (pod_id) {
|
|
30
|
-
extras["pod-id"] = pod_id;
|
|
31
|
-
}
|
|
32
|
-
if (pod_shortname) {
|
|
33
|
-
extras["pod-shortname"] = pod_shortname;
|
|
34
|
-
}
|
|
35
|
-
if (pod_region) {
|
|
36
|
-
extras["pod-region"] = pod_region;
|
|
37
|
-
}
|
|
38
|
-
if (pod_account) {
|
|
39
|
-
extras["pod-account"] = pod_account;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return JSON.stringify(_.extend(extras, data), replaceErrors);
|
|
43
|
-
}
|
|
44
|
-
return JSON.stringify(data, replaceErrors);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Similar to format, but takes additional reserved params to promote logging best-practices
|
|
48
|
-
function formatLog(source = "", level = "", title = "", data = {}) {
|
|
49
|
-
let info = data;
|
|
50
|
-
if (!_.isObject(data)) {
|
|
51
|
-
info = {};
|
|
52
|
-
}
|
|
53
|
-
const reserved = { source, level, title };
|
|
54
|
-
|
|
55
|
-
// reserved keys overwrite other keys in data
|
|
56
|
-
return format(_.extend({}, info, reserved));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports = {
|
|
60
|
-
format,
|
|
61
|
-
formatLog,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const LOG_LEVELS = {
|
|
65
|
-
UNKNOWN: "unknown",
|
|
66
|
-
CRITICAL: "critical",
|
|
67
|
-
ERROR: "error",
|
|
68
|
-
WARNING: "warning",
|
|
69
|
-
INFO: "info",
|
|
70
|
-
TRACE: "trace",
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
_.extend(module.exports, LOG_LEVELS);
|
package/lib/logger/helpers.ts
DELETED
|
File without changes
|