forked from joshuaslate/saas-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·32 lines (26 loc) · 944 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
// Include our packages in our main server file
const express = require('express');
app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const passport = require('passport');
const config = require('./config/main');
const cors = require('cors');
const 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'));
// Home route. We'll end up changing this to our main front end index later.
app.get('/', function(req, res) {
res.send('Relax. We will put the home page here later.');
});
// Connect to database
mongoose.connect(config.database);
require('./app/routes')(app);
// Start the server
app.listen(port);
console.log('Your server is running on port ' + port + '.');