forked from BreakApp/BreakApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (24 loc) · 1010 Bytes
/
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
'use strict';
var express = require('express');
var bodyparser = require('body-parser');
var mongoose = require('mongoose');
var http = require('http');
var passport = require('passport');
var compression = require('compression');
var app = express();
mongoose.connect(process.env.MONGO_URL || 'mongodb://127.0.0.1:27017/breaks' || 'mongodb://localhost/breaks');
app.use(compression());
app.use(express.static(__dirname + (process.env.STATIC_DIR || '/dist')));
app.set('jwtTokenSecret', process.env.JWT_SECRET ||'developmentsecret');
app.set('secret', process.env.SECRET ||'developmentsecret');
app.use(passport.initialize());
require('./lib/passport')(passport);
var jwtauth = require('./lib/jwtauth')(app);
app.use(bodyparser.json());
require('./routes/break-routes')(app, jwtauth.auth);
require('./routes/user-routes')(app, passport);
var server = http.createServer(app);
var port = process.env.PORT || 3000;
server.listen(port, function() {
console.log('server running on port ' + port);
});