-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
39 lines (30 loc) · 1.05 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
// Include our packages in our main server file
const express = require('express');
app = express();
const mongoose = require('mongoose');
const morgan = require('morgan');
const passport = require('passport');
const bodyParser = require('body-parser');
const config = require('./config/main');
const cors = require('cors');
const events = require('events');
const port = process.env.PORT || 3000;
// Use body-parser to get POST requests for API use
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());
// Log requests to console
app.use(morgan('dev'));
// Connect to database
mongoose.connect(config.database);
// Load data from Marvel if absent
require('./scripts/data_loader')();
app.use(passport.initialize());
require('./config/passport')(passport);
require('./app/routes/user_routes')(app);
require('./app/routes/hero_routes')(app);
var server = require('http').createServer(app);
// Start the server
server.listen(port);
console.log('server is running on port ' + port + '.');
require('./app/chat/chat_socket')(server);