@certik/skynet 0.10.37 → 0.10.38
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/CHANGELOG.md +4 -0
- package/api.js +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/api.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const osModule = require("os");
|
|
1
2
|
const express = require("express");
|
|
2
3
|
const meow = require("meow");
|
|
3
4
|
const { getJobName, getSelectorFlags, getSelectorDesc } = require("./selector");
|
|
@@ -13,10 +14,18 @@ async function logStartMiddleware(req, res, next) {
|
|
|
13
14
|
next();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
async function contextMiddleware(req, res, next) {
|
|
18
|
+
res.set("x-instance-id", osModule.hostname());
|
|
19
|
+
|
|
20
|
+
next();
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
async function logEndMiddleware(req, res, next) {
|
|
17
24
|
const start = new Date(res.get("x-requested-at"));
|
|
18
25
|
const end = new Date();
|
|
19
26
|
|
|
27
|
+
res.set("x-responded-at", end.toISOString());
|
|
28
|
+
|
|
20
29
|
const logInfo = {
|
|
21
30
|
start,
|
|
22
31
|
end,
|
|
@@ -134,6 +143,7 @@ ${getSelectorDesc(selector)}
|
|
|
134
143
|
|
|
135
144
|
app[method](
|
|
136
145
|
route.path,
|
|
146
|
+
contextMiddleware,
|
|
137
147
|
logStartMiddleware,
|
|
138
148
|
...middlewares,
|
|
139
149
|
async (req, res, next) => {
|