-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
35 lines (24 loc) · 936 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
const express = require('express'),
bodyParser = require('body-parser'),
cors = require('cors'),
mongoose = require('mongoose'),
path = require('path');
app = express();
app.use(cors());
app.use(bodyParser.urlencoded({extended : true}));
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
var isProduction = process.env.NODE_ENV === 'production';
var MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost/meanstackdb';
if(isProduction){
mongoose.connect(process.env.MONGODB_URI);
} else {
mongoose.connect("mongodb://ganeshmani:[email protected]:53284/mean_kickstarter",{ useNewUrlParser : true });
mongoose.set('debug', true);
}
require('./model/post');
app.use(require('./routes/posts'))
const PORT = process.env.PORT || 3000;
app.listen(PORT,() => {
console.log(`app is listening to port ${PORT}`);
})