-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (19 loc) · 729 Bytes
/
Copy pathindex.js
File metadata and controls
25 lines (19 loc) · 729 Bytes
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
const express = require('express');
const app = express();
// The service port defaults to 3000 or is read from the program arguments
const port = process.argv.length > 2 ? process.argv[2] : 3000;
// Text to display for the service name
const serviceName = process.argv.length > 3 ? process.argv[3] : 'website';
// Serve up the static content
app.use(express.static('public'));
// Provide the version of the application
app.get('/config', (_req, res) => {
res.send({ version: '20221228.075705.1', name: serviceName });
});
// Return the homepage if the path is unknown
app.use((_req, res) => {
res.sendFile('index.html', { root: 'public' });
});
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});