-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (23 loc) · 968 Bytes
/
app.js
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
const express = require('express');
const cors = require('cors');
const logger = require('./lib/logger');
const updateChangefilesExample = require('./lib/controllers/changefiles');
const routerSnapshots = require('./lib/routers/snapshots');
const routerChangeFiles = require('./lib/routers/changefiles');
const routerPing = require('./lib/routers/ping');
// start server
const app = express();
app.use('/snapshots', cors());
app.use(express.json());
app.use(routerSnapshots);
app.use(routerChangeFiles);
app.use(routerPing);
/* Errors and unknown routes */
app.use((req, res, next) => res.status(404).json({ message: `Cannot ${req.method} ${req.originalUrl}` }));
app.use((error, req, res, next) => res.status(500).json({ message: error.message }));
app.listen(3000, async () => {
logger.info('[express] fakeUnpaywall service listening on 3000');
await updateChangefilesExample('day');
await updateChangefilesExample('week');
});
module.exports = app;