-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (36 loc) · 1.49 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
require('use-strict');
let express = require('express'),
app = express(),
bodyParser = require('body-parser'),
hbs = require('hbs'),
mongoose = require('mongoose'),
cors = require('cors'),
morgan = require('morgan'),
//auth
passport = require('passport'),
jwt = require('jwt-simple'),
apiController = require('./controllers/apiController'),
config = require('./config/config'),
routes = require('./config/routes');
// TODO: configure a development and deployment strategy for cross origin
app.use(cors());
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
// Log to console
app.use(morgan('dev'));
app.use(passport.initialize());
// Set default to serve static files from public folder
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/bower_components'));
// TODO: revisit how the front end will be rendered, using handlebars
app.set('view engine', 'hbs');
// TODO: determine database strategy for deployment vs local development
// mongoose.connect( process.env.MONGOLAB_URI ||
// process.env.MONGOHQ_URL ||
// config.database);
require('./config/passport')(passport);
app.listen(process.env.PORT || 3000, () => {
console.log(`Server is up on port ${process.env.PORT || '3000'}`);
});
mongoose.connect(config.database);
app.use(routes);