zsyp 1.4.1 → 1.5.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/lib/app.js +2 -0
- package/lib/ping.js +26 -0
- package/package.json +5 -2
package/lib/app.js
CHANGED
|
@@ -3,6 +3,7 @@ const connect = require('@pirxpilot/connect');
|
|
|
3
3
|
const mniam = require('mniam');
|
|
4
4
|
const router = require('./router');
|
|
5
5
|
const event = require('./event');
|
|
6
|
+
const ping = require('./ping');
|
|
6
7
|
|
|
7
8
|
module.exports = makeApp;
|
|
8
9
|
|
|
@@ -18,6 +19,7 @@ function makeApp(opts = {}) {
|
|
|
18
19
|
|
|
19
20
|
app.use('/csp', router({ ...opts, name: 'csp', domains }));
|
|
20
21
|
app.use('/event', router({ ...opts, converter: event.converter }));
|
|
22
|
+
app.use('/_/ping', ping(opts));
|
|
21
23
|
|
|
22
24
|
return app;
|
|
23
25
|
}
|
package/lib/ping.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = makePing;
|
|
2
|
+
|
|
3
|
+
function makePing({ db }) {
|
|
4
|
+
const pingsCollection = db.collection({ name: 'ping' });
|
|
5
|
+
|
|
6
|
+
return ping;
|
|
7
|
+
|
|
8
|
+
async function ping(req, res) {
|
|
9
|
+
if (req.method !== 'GET' && req.path !== '/') {
|
|
10
|
+
res.statusCode = 404;
|
|
11
|
+
res.end();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
await pingsCollection.insertOne({
|
|
16
|
+
timestamp: new Date()
|
|
17
|
+
});
|
|
18
|
+
res.statusCode = 204; // empty
|
|
19
|
+
res.end();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error(error);
|
|
22
|
+
res.statusCode = 500;
|
|
23
|
+
res.end();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zsyp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "CSP violation reports logger.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
7
7
|
"email": "pirxpilot@furkot.com",
|
|
8
8
|
"url": "https://pirxpilot.me"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/pirxpilot/zsyp.git"
|
|
13
|
+
},
|
|
11
14
|
"license": "MIT",
|
|
12
15
|
"keywords": [
|
|
13
16
|
"zsyp",
|