-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
62 lines (49 loc) · 1.78 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
// server.js
// Set Up =======================================
var express = require('express')
, app = express()
, port = process.env.PORT || 8080
, mongoose = require('mongoose')
, passport = require('passport')
, flash = require('connect-flash')
, path = require('path')
, sass = require('node-sass');
var configDB = require('./config/database.js');
// Configuration ================================
// DB Connection
mongoose.connect(configDB.url);
// Passport Config
require('./config/passport.js')(passport);
// Application Config
app.configure(function() {
// Compress the files before sending
app.use(express.compress());
// set up the express application
app.use(express.logger('dev')); // log every request to the console
app.use(express.cookieParser()); // Cookies (Needed for authorization)
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.set('view engine', 'jade'); // Jade templating engine
// required for passport
app.use(express.session({ secret: 'artsyVageesh' })); // Secret Session
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use(flash()); // Using flash messages stored in sessions
// Stylesheets
app.use(
sass.middleware({
src: __dirname + '/sass',
dest: __dirname + '/public',
outputStyle: 'compressed'
})
);
app.use(express.static(path.join(__dirname, 'public'))); //Serve stylesheets
});
// Routes ======================================================================
// Load our routes
require('./app/routes.js')(app, passport);
// Launch ======================================================================
app.listen(port, function() {
console.log('Server is up and listening to: ' + port);
});