-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (29 loc) · 833 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
34
35
36
37
const express = require('express');
const debug = require('debug')('Emerald');
const cors = require('cors');
require('dotenv').config();
const mongooseInit = require('./mongoDB');
const app = express();
const indexRouter = require('./routes/index');
const userRouter = require('./routes/users');
const familyRouter = require('./routes/family');
// DB Init
mongooseInit();
// middleware setup
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// Route
app.use('/', indexRouter);
app.use('/', userRouter);
app.use('/', familyRouter);
app.get('*', (req, res) => {
res.sendStatus(404);
});
app.post('*', (req, res) => {
res.sendStatus(404);
});
app.listen(process.env.EXPRESS_PORT, () => {
debug(`Server is running at port::${process.env.EXPRESS_PORT}`);
});
module.exports = app;