Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bytesleo committed Apr 5, 2018
1 parent 783c620 commit ace080f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodetomic-api-swagger",
"version": "3.4.1",
"version": "3.4.2",
"description": "RESTful API Nodejs designed for horizontal scalability with support for cluster, based on Swagger, Redis, JWT, Passport, Socket.io, Express, MongoDB.",
"main": "src/app.js",
"repository": {
Expand Down
1 change: 0 additions & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default {
// uri: mongodb://username:password@host:port/database?options
uri: `mongodb://localhost:27017/${DB_NAME}`,
options: {
useMongoClient: true
},
seed: {
path: '/api/models/seeds/',
Expand Down
1 change: 0 additions & 1 deletion src/config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default {
// uri: mongodb://username:password@host:port/database?options
uri: `mongodb://localhost:27017/${DB_NAME}`,
options: {
useMongoClient: true
},
seed: {
path: '/api/models/seeds/',
Expand Down
9 changes: 5 additions & 4 deletions src/lib/mongoose/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ mongoose.Promise = global.Promise;
export async function connect() {

try {
let conn = await mongoose.connect(uri, opts);
const conn = await mongoose.connect(uri, opts);
const db = mongoose.connection;

// Events
conn.on('disconnected', (err) => {
db.on('disconnected', (err) => {
console.log(chalk.redBright(`MongoDB-> disconnected: ${uri}`));
connect();
});

conn.on('reconnected', (err) => {
db.on('reconnected', (err) => {
console.log(chalk.greenBright(`MongoDB-> reconnected: ${uri}`));
});

Expand All @@ -35,7 +36,7 @@ export async function connect() {
}
}
// Plant seed
await require('./seed').default(conn, config);
await require('./seed').default(db, config);

} catch (err) {
console.log(chalk.redBright(`MongoDB-> connection error: ${uri} details->${err}`));
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import assert from 'assert';
import request from 'request';
import config from '../src/config';

describe('Server', () => {
describe('/', () => {

const host = `http://${config.server.ip}:${config.server.port}`;

Expand Down

0 comments on commit ace080f

Please sign in to comment.