-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
65 lines (49 loc) · 1.72 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
59
60
61
62
63
64
65
/*
Here is where you set up your server file.
express middleware.
*/
var Sequelize = require('sequelize'),
connection;
if (process.env.JAWSDB_URL){
connection = new Sequelize(process.env.JAWSDB_URL);
} else{
connection = new Sequelize('bucketlist', 'root', 'password', {
host: 'localhost',
dialect: 'mysql',
port:'3306'
})
}
var express = require('express');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var passport = require('passport');
var flash = require('connect-flash');
var morgan = require('morgan'); //logger
var cookieParser = require('cookie-parser'); //parse cookies
var session = require('express-session'); //session middleware
var app = express();
// require('./config/passport')(passport); //passes passport for configuration
// Serve static content for the app from the "public" directory in the application directory.
app.use(express.static(__dirname + '/public'));
app.use(morgan('dev')); //log every request to the console
app.use(cookieParser()); //read cookies, needed for auth
app.use(bodyParser.urlencoded({
extended: false
}));
//Passport dependencies
app.use(session({ secret: 'RutProject2'})); //session secret
app.use(passport.initialize());
app.use(passport.session()); //persisten login sessions
app.use(flash()); //use connect-flash for messages stored in session
// override with POST having ?_method=DELETE
app.use(methodOverride('_method'));
var exphbs = require('express-handlebars');
app.engine('handlebars', exphbs({
defaultLayout: 'main'
}));
app.set('view engine', 'handlebars');
var routes = require('./controllers/bl_controller.js');
app.use('/', routes);
var PORT = 3000;
// app.listen(port);
app.listen(process.env.PORT || PORT);