UNPKG

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