1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-26 10:43:35 +02:00

react-express-mongodb: lint sources

to fix some syntax issues in the existing code, the commit
put in place prettier and format the code

Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
This commit is contained in:
Jérémie Drouet 2020-05-12 15:16:03 +02:00 committed by Guillaume Lours
parent be8875c9b6
commit be7f09b6ba
12 changed files with 149 additions and 140 deletions

View file

@ -1,30 +1,32 @@
/**
* Created by Syed Afzal
*/
const mongoose = require('mongoose');
const {log} = require('../utils/helpers/logger');
const mongoose = require("mongoose");
exports.connect = (app) => {
const options = {
useNewUrlParser: true,
autoIndex: false, // Don't build indexes
reconnectTries: 30, // Retry up to 30 times
reconnectInterval: 500, // Reconnect every 500ms
poolSize: 10, // Maintain up to 10 socket connections
// If not connected, return errors immediately rather than waiting for reconnect
bufferMaxEntries: 0
}
const options = {
useNewUrlParser: true,
autoIndex: false, // Don't build indexes
reconnectTries: 30, // Retry up to 30 times
reconnectInterval: 500, // Reconnect every 500ms
poolSize: 10, // Maintain up to 10 socket connections
// If not connected, return errors immediately rather than waiting for reconnect
bufferMaxEntries: 0,
};
const connectWithRetry = () => {
mongoose.Promise = global.Promise;
console.log('MongoDB connection with retry')
mongoose.connect(process.env.MONGODB_URI, options).then(()=>{
console.log('MongoDB is connected');
app.emit('ready');
}).catch(err=>{
console.log('MongoDB connection unsuccessful, retry after 2 seconds.')
setTimeout(connectWithRetry, 2000)
})
}
connectWithRetry();
const connectWithRetry = () => {
mongoose.Promise = global.Promise;
console.log("MongoDB connection with retry");
mongoose
.connect(process.env.MONGODB_URI, options)
.then(() => {
console.log("MongoDB is connected");
app.emit("ready");
})
.catch((err) => {
console.log("MongoDB connection unsuccessful, retry after 2 seconds.");
setTimeout(connectWithRetry, 2000);
});
};
connectWithRetry();
};