Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GroupCNorthwind/server.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
56 lines (45 sloc)
1.81 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.js | |
// set up ====================================================================== | |
// get all the tools we need | |
var express = require('express'); | |
var session = require('express-session'); | |
var cookieParser = require('cookie-parser'); | |
var bodyParser = require('body-parser'); | |
var morgan = require('morgan'); | |
var app = express(); | |
var port = process.env.PORT || 8000; | |
var passport = require('passport'); | |
var flash = require('connect-flash'); | |
// configuration =============================================================== | |
// connect to our database | |
require('./public/config/passport')(passport); // pass passport for configuration | |
// set up our express application | |
app.use(morgan('dev')); // log every request to the console | |
app.use(cookieParser()); // read cookies (needed for auth) | |
app.use(bodyParser.urlencoded({ | |
extended: true, | |
limit: '50mb' | |
})); | |
app.use(bodyParser.json( { | |
limit: '50mb' | |
})); | |
//app.set('view engine', 'ejs'); // set up ejs for templating | |
// required for passport | |
app.use(session({ | |
secret: 'secret', | |
resave: true, | |
saveUninitialized: true | |
} )); // session secret | |
app.use(passport.initialize()); | |
app.use(passport.session()); // persistent login sessions | |
app.use(flash()); // use connect-flash for flash messages stored in session | |
app.use(express.static(__dirname + '/' + 'public')); | |
app.set('views', __dirname + '/public/views'); | |
app.engine('html', require('ejs').renderFile); | |
app.set('view engine', 'html'); | |
// routes ====================================================================== | |
require('./public/app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport | |
require('./public/config/testing')(app); | |
// launch ====================================================================== | |
app.listen(port); | |
console.log('Listening on port ' + port); |