-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
35 lines (28 loc) ยท 1.3 KB
/
start.js
File metadata and controls
35 lines (28 loc) ยท 1.3 KB
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
const mongoose = require('mongoose');
// Make sure we are running node 7.6+
const [major, minor] = process.versions.node.split('.').map(parseFloat);
if (major < 7 || (major === 7 && minor <= 5)) {
console.log('๐ ๐ฎ ๐ถ ๐ช ๐ฉ\nHey You! \n\t ya you! \n\t\tBuster! \n\tYou\'re on an older version of node that doesn\'t support the latest and greatest things we are learning (Async + Await)! Please go to nodejs.org and download version 7.6 or greater. ๐\n ');
process.exit();
}
// 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);
mongoose.Promise = global.Promise; // Tell Mongoose to use ES6 promises
mongoose.connection.on('error', (err) => {
console.error(`๐
๐ซ ๐
๐ซ ๐
๐ซ ๐
๐ซ โ ${err.message}`);
});
// READY?! Let's go!
//import the models here ***********
require('./models/Store.js');
require('./models/User.js');
require('./models/Review.js');
// Start our app!
const app = require('./app');
app.set('port', process.env.PORT || 7777);
const server = app.listen(app.get('port'), () => {
console.log(`Express running โ PORT ${server.address().port}`);
});
//temp mail send execution
//require('./handlers/mail');