-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
44 lines (29 loc) · 1.25 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
var express = require('express');
// parses cookies for root scope. To keep the session, we need info
// in cookies
var cookieParser = require('cookie-parser');
var session = require('express-session');
var passport = require('passport'); //core passport library initialized here
var app = express();
// var connectionString = 'mongodb://127.0.0.1:27017/taportal';
var connectionString = 'mongodb://admin:admin@ds149567.mlab.com:49567/taportal';
var mongoose = require("mongoose");
mongoose.connect(connectionString);
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
/* VVVIP : session has to be initialized AFTER Cookie Parser */
app.use(cookieParser());
app.use(session({secret: "asdfsfsdf"}));
// First initialize passport and then tell it to use the express session
app.use(passport.initialize());
app.use(passport.session());
// configure a public directory to host static content
app.use(express.static(__dirname + '/public'));
//require ("./test/app.js")(app);
var ipaddress = process.env.OPENSHIFT_NODEJS_IP;
var port = process.env.OPENSHIFT_NODEJS_PORT || 3000;
var project = require("./project/app.js");
project(app);
app.listen(port, ipaddress);
module.exports = app;