-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (20 loc) · 819 Bytes
/
server.js
File metadata and controls
26 lines (20 loc) · 819 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
26
const express = require('express');
const pino = require('express-pino-logger')();
const autoindexJson = require('autoindex-json');
// initiate express server
const app = express();
app.use(pino);
// constants
const PORT = process.env.ODOVIZ_PORT || 3000;
const DATA_DIR = process.env.ODOVIZ_DATA_DIR;
if (DATA_DIR == null) {
console.error('Please specify ODOVIZ_DATA_DIR environment variable before initializing OdoViz');
process.exit();
}
// autoindex json api at /files for DATA_DIR
app.use('/files', express.static(DATA_DIR), autoindexJson(DATA_DIR, { onErrorStatus4xx: false }));
// serve software at /
// make sure you build the client beforehand
app.use('/', express.static('client/build'));
// start server
app.listen(PORT, () => console.log(`Express server is running on http://localhost:${PORT}`));