Skip to content

Commit 2fe2fc2

Browse files
Merge pull request #9 from giuseppealbrizio/development
mongoose promise setup added
2 parents 55cf4be + 6e44322 commit 2fe2fc2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/config/database.config.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1+
import debug from 'debug';
12
import mongoose from 'mongoose';
23

3-
import debug from 'debug';
4+
mongoose.connection.on('connected', () => {
5+
console.log('MongoDB Connection Established');
6+
});
7+
8+
mongoose.connection.on('reconnected', () => {
9+
console.log('MongoDB Connection Reestablished');
10+
});
11+
12+
mongoose.connection.on('disconnected', () => {
13+
console.log('MongoDB Connection Disconnected');
14+
});
15+
16+
mongoose.connection.on('close', () => {
17+
console.log('MongoDB Connection Closed');
18+
});
19+
20+
mongoose.connection.on('error', (error) => {
21+
console.log(`MongoDB ERROR: ${error}`);
22+
23+
process.exit(1);
24+
});
425

526
const DEBUG = debug('dev');
627

0 commit comments

Comments
 (0)