-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
51 lines (41 loc) · 1.41 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require('dotenv').config();
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
const userRouter = require('./routes/userRoutes.js');
app.use('/user',userRouter);
const bookmarkRouter = require('./routes/bookmarkRoutes.js');
app.use('/bookmark',bookmarkRouter);
switch(process.env.mode){
case 'development':
process.env.DATABASE = process.env.DevelopmentDatabase;
process.env.PORT = process.env.DevelopmentPort;
break;
case 'local':
process.env.DATABASE = process.env.LocalDatabase;
process.env.PORT = process.env.LocalPort;
break;
case 'test':
process.env.DATABASE = process.env.TestDataBase;
process.env.PORT = process.env.TestPort;
break;
default:
process.env.DATABASE = process.env.DevelopmentDatabase;
process.env.PORT = process.env.DevelopmentPort;
break;
}
if(process.env.mode != 'production'){
console.log('DATABASE => ' + process.env.DATABASE);
console.log('PORT => ' + process.env.PORT);
}
mongoose.connect(process.env.DATABASE, {useNewUrlParser: true });
mongoose.set('debug',true);
app.listen(5000,function(){
console.log('Server is running on 5000');
});
module.exports = app;