-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.mjs
More file actions
33 lines (27 loc) · 736 Bytes
/
app.mjs
File metadata and controls
33 lines (27 loc) · 736 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
27
28
29
30
31
32
33
import express from 'express';
import { startup } from './lib/db.mjs';
import current from './routes/current.mjs';
import all from './routes/all.mjs';
import sparkline from './routes/sparkline.mjs';
import update from './routes/update.mjs';
const app = express();
const port = process.env.PORT || 3000;
app.use('/app/current', current);
app.use('/app/all', all);
app.use('/app/sparkline', sparkline);
app.use('/app/update', update);
app.use((err, req, res, next) => {
console.error(err.stack);
if (res.headersSent) {
next(err);
return;
}
res.status(500);
res.send('kablooie!');
});
async function main() {
startup()
.catch((err) => console.error(err.stack))
.finally(() => app.listen(port));
}
main();