-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (24 loc) · 822 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
import express from 'express';
import bodyParser from 'body-parser';
import createError from 'http-errors';
import dotenv from 'dotenv';
import rollRouter, { ROLL_END_POINT } from './routes/rollRouter';
import weatherRouter, { WEATHER_END_POINT } from './routes/weatherRouter';
dotenv.config({ path: 'config/.env' });
// Set up the express app
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(ROLL_END_POINT, rollRouter);
app.use(WEATHER_END_POINT, weatherRouter);
app.get('*', (req, res) => {
var err = createError(
404, 'Invalid endpoint.', { success: 'false' }
);
res.send(err);
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
// eslint-disable-next-line no-console
console.log(`server running on port ${PORT}`);
});