forked from MennaAnees/registration-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·34 lines (26 loc) · 890 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
require('dotenv').config();
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const userController = require('./controllers/user');
const statusController = require('./controllers/status');
const { authMiddleware } = require('./middlewares');
const mongoURL = process.env.MONGO_URL || 'mongodb://localhost:27017/form';
mongoose.connect(mongoURL, { useNewUrlParser: true }, (err) => {
if (err) {
console.log(err);
return;
}
console.log('db connected');
});
app.use(bodyParser.json());
// app.use(bodyParser.urlencoded({ extended: false }));
app.use('/user', userController);
app.use(authMiddleware);
app.use('/status', statusController);
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`app is listening on port ${port}`);
});
module.exports = app;