-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
executable file
·40 lines (30 loc) · 1.17 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
// Require our dependecies
var express = require("express");
var mongoose = require("mongoose");
var bluebird = require("bluebird");
var bodyParser = require("body-parser");
var passport = require('passport');
var session = require('express-session');
var PORT = process.env.PORT || 4000;
mongoose.Promise = bluebird;
var app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(__dirname + "/public"));
app.use(session({ secret: 'keyboard cat', resave: true, saveUninitialized: true }));
app.use(passport.initialize());
app.use(passport.session());
var routes = require("./routes/routes");
app.use("/", routes);
// var mongoDB = "mongodb://heroku_qwcxn1pp:[email protected]:39879/heroku_qwcxn1pp" ;
var mongoDB = "mongodb://localhost/givingGoodsApp";
mongoose.connect(mongoDB, {
useMongoClient: true
});
//Get the default connection
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
// Start the server
app.listen(PORT, function () {
console.log("Visit localhost:%s in your browser.", PORT);
});