diff --git a/.eslintrc.json b/.eslintrc.json index 6d41203..560e01b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,7 +6,7 @@ "promise" ], "parserOptions": { - "ecmaVersion": 6 + "ecmaVersion": 2017 }, "globals": { "$": true diff --git a/app.js b/app.js index d2c6ef4..1313e35 100644 --- a/app.js +++ b/app.js @@ -260,16 +260,22 @@ app.use((err, req, res, next) => { }); }); +// Nodejs version check +if(parseInt(process.version.split('.')[0].replace('v', '')) <= 7){ + console.log(colors.red('Please use Node.js version 7.x or above')); + process.exit(2); +} + app.on('uncaughtException', (err) => { console.error(colors.red(err.stack)); - process.exit(); + process.exit(2); }); MongoClient.connect(config.databaseConnectionString, {}, (err, client) => { // On connection error we display then exit if(err){ console.log(colors.red('Error connecting to MongoDB: ' + err)); - process.exit(); + process.exit(2); } // select DB @@ -281,22 +287,22 @@ MongoClient.connect(config.databaseConnectionString, {}, (err, client) => { db.products = db.collection('products'); db.orders = db.collection('orders'); db.pages = db.collection('pages'); + db.menu = db.collection('menu'); // add db to app for routes app.db = db; // add indexing common.runIndexing(app) - .then(common.testData(db)) + .then(common.testData(db, app)) + .then(app.listen(app.get('port'))) .then(() => { // lift the app - app.listen(app.get('port'), () => { - console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port'))); - }); + console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port'))); }) .catch(() => { console.error(colors.red('Error setting up indexes:' + err)); - process.exit(); + process.exit(2); }); }); diff --git a/bin/testdata.json b/bin/testdata.json index bd94d2b..f42fd86 100644 --- a/bin/testdata.json +++ b/bin/testdata.json @@ -1,67 +1,83 @@ -[ - { - "productPermalink": "duckworth-jacket", - "productTitle": "Duckworth Woolfill Jacket", - "productPrice": "188.00", - "productDescription": "

Inspired by the timeless, functional style of your grandfather's work coat, the Foraker features brass buttons and 4 patch pockets. Crafted in Bristol, Tennessee, our 10oz organic duck canvas is light enough for an early summer morning, but rugged enough to handle your days work.<\/p>