-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
58 lines (45 loc) · 1.53 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
54
55
56
57
58
//REQUIREMENTS
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var morgan = require('morgan');
var passport = require('passport');
var passportLocal = require('passport-local');
var session = require('express-session');
// var route = require('angular-route');
//setting up port/DB, requiring mongoose
var port = process.env.PORT || 3000;
var mongoose = require('mongoose');
var mongoURI = process.env.MONGOLAB_URI || 'mongodb://localhost/wine_not';
//pass port config load
require('./config/passport')(passport);
//middleware
app.use(express.static('public'))
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// app.use(methodOverride('_method'));
//passport middleware
var passport = require('passport');
var session = require('express-session');
app.use(session({name: 'wine_not_auth_app', secret: 'wine'}));
app.use(passport.initialize());
app.use(passport.session());
//controllers
var userController = require('./controllers/userController.js');
app.use('/user', userController);
// var locationController = require('./controllers/locationController.js');
// app.use('/location', locationController);
//mongoose
mongoose.connect(mongoURI);
mongoose.connection.on('error', function(){
console.log('MONGO not connected');
})
//port
mongoose.connection.once('open', function(){
console.log('MONGO connected');
app.listen(port, function(){
console.log("Listening on port:" + port);
});
});