generated from Technigo/express-api-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
34 lines (26 loc) · 839 Bytes
/
server.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
34
// /* eslint-disable no-console */
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import animalRoutes from './animal/animalRoutes';
import gameRoutes from './game/gameRoutes';
import userRoutes from './user/userRoutes';
require('dotenv').config();
const PORT = process.env.PORT || 8080;
const app = express();
app.use(bodyParser.json());
app.use(cors());
app.use('/animals', animalRoutes);
app.use('/games', gameRoutes);
app.use('/users', userRoutes);
const listEndpoints = require('express-list-endpoints');
app.get('/', (req, res) => {
res.json(listEndpoints(app));
});
app.get('*', (req, res) => {
res.status(404).send('404 Not Found');
});
app.listen(PORT, () => {
// eslint-disable-next-line no-console
console.log(`🚀 Server running on http://localhost:${PORT}`);
});