-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
53 lines (40 loc) · 1.31 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var express = require('express');
var app = express();
var apiRouter = express.Router();
var adminRouter = express.Router();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var debug = require('debug')('overbrook:server');
var multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads')
},
filename: function (req, file, cb) {
console.log('FILE FROM FILE NAME : ', file.originalname);
cb(null, file.originalname)
}
})
// PRODUCTION _________________
var mongoURI = process.env.MONGOLAB_URI || 'mongodb://localhost/dev';
// STAGING ____________________
// var mongoURI = 'mongodb://overbrook:[email protected]:11903/overbrook-construction';
debug('mongoURI ' + mongoURI);
var origin = process.env.ORIGIN || 'http://localhost:8080';
// var origin = 'https://overbrook-client.herokuapp.com'
var cors = require('cors');
mongoose.connect(mongoURI);
require('./routes/email-route')(apiRouter);
require('./routes/addHomes-route')(apiRouter);
var corsOptions = {
origin: origin
};
app.use(cors(corsOptions));
app.use(bodyParser.json());
app.use(multer({
storage: storage
}).any());
app.use('/', apiRouter);
app.listen(process.env.PORT || 3000, function() {
console.log('Server started on port 3000');
});