From 4a2f1eb4fea25732ce8a55120d162f9911b2ee17 Mon Sep 17 00:00:00 2001 From: Hunter Rafuse <31886722+HunterRafuse@users.noreply.github.com> Date: Sat, 13 Oct 2018 10:13:25 +0300 Subject: [PATCH] Update app.js update connection method --- app.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index b271e4b..0d1afa8 100644 --- a/app.js +++ b/app.js @@ -8,12 +8,19 @@ const productRoutes = require("./api/routes/products"); const orderRoutes = require("./api/routes/orders"); const userRoutes = require('./api/routes/user'); -mongoose.connect( - "mongodb://node-shop:" + - process.env.MONGO_ATLAS_PW + - "@node-rest-shop-shard-00-00-wovcj.mongodb.net:27017,node-rest-shop-shard-00-01-wovcj.mongodb.net:27017,node-rest-shop-shard-00-02-wovcj.mongodb.net:27017/test?ssl=true&replicaSet=node-rest-shop-shard-0&authSource=admin", - { - useMongoClient: true + +mongoose.connect(uri, options).then( + () => { + "mongodb://node.shop:" + + process.env.MONGO_ATLAS_PW + + "@node-rest-shop-shard-00-00-wovcj.mongodb.net:27017,node-rest-shop-shard-00-01-wovcj.mongodb.net:27017,node-rest-shop-shard-00-02-wovcj.mongodb.net:27017/test?ssl=true&replicaSet=node-rest-shop-shard-0&authSource=admin", + { + useMongoClient: true + } + }, + .catch((err) => { + console.log('Error on start: ' + err.stack); + process.exit(1); } ); mongoose.Promise = global.Promise;