forked from RafalWilinski/express-status-monitor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
51 lines (43 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* eslint no-console: "off" */
const socketIoPort = 2222;
const express = require('express');
// This is optional. If your server uses socket.io already, pass it to config as `webserver` along with it's port.
const socketio = require('socket.io')(socketIoPort);
const app = express();
const port = process.env.PORT || 3000;
app.use(
require('../index')({
path: '/',
// Use existing socket.io instance.
// websocket: socketio,
// Ignore requests which req.path begins with
// ignoreStartsWith: '/return-status',
// Pass socket.io instance port down to config.
// Use only if you're passing your own instance.
// port: socketIoPort,
healthChecks: [
{
protocol: 'http',
host: 'localhost',
port: 3000,
path: '/admin/health/ex1',
headers: {},
},
{
protocol: 'http',
host: 'localhost',
port: 3000,
path: '/return-status/200',
headers: {},
},
],
}),
);
app.use(require('express-favicon-short-circuit'));
// Example route throwing requested status code
app.get('/return-status/:statusCode', (req, res) =>
res.sendStatus(req.params.statusCode),
);
app.listen(port, () => {
console.log(`Listening on http://0.0.0.0:${port}`);
});