-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
29 lines (24 loc) · 897 Bytes
/
start.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
const mongoose = require('mongoose');
// import environmental variables from our variables.env file
require('dotenv').config({ path: 'variables.env' });
// Connect to our Database and handle any bad connections
mongoose.connect(
process.env.DATABASE,
{ useNewUrlParser: true }
);
mongoose.Promise = global.Promise; // Tell Mongoose to use ES6 promises
mongoose.connection.on(
'error',
({ message }) => console.error(`🙅 🚫 🙅 🚫 🙅 🚫 🙅 🚫 → ${message}`) // eslint-disable-line no-console
);
// READY?! Let's go!
// Import our models
require('./models/Store');
require('./models/User');
require('./models/Review');
// Start our app!
const app = require('./index');
app.set('port', process.env.PORT || 7777);
const server = app.listen(app.get('port'), () => {
console.log(`Express running → PORT ${server.address().port}`); // eslint-disable-line no-console
});