-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.mjs
35 lines (29 loc) · 820 Bytes
/
app.mjs
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
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) => {
// eslint-disable-next-line no-console
console.error(err.stack);
if (res.headersSent) {
next(err);
return;
}
res.status(500);
res.send('kablooie!');
});
async function main() {
startup()
// eslint-disable-next-line no-console
.catch((err) => console.error(err.stack))
.finally(() => app.listen(port));
}
main();