index.js 896 Bytes
Newer Older
Ha YeaJin's avatar
pages    
Ha YeaJin committed
1
2
3
4
5
6
7
const mongoose = require('mongoose');

module.exports = () => {
    const connect = () => {
        if (process.env.NODE_ENV !== 'production') {
            mongoose.set('debug', true);
        }
Lee Jin Ju's avatar
Lee Jin Ju committed
8
        mongoose.connect('mongodb://hijinju:highlight@localhost:27017/admin', {
Lee Jin Ju's avatar
.    
Lee Jin Ju committed
9
            dbName: 'ku_rental',
Ha YeaJin's avatar
pages    
Ha YeaJin committed
10
11
12
13
14
15
16
17
18
19
20
21
22
        }, (error) => {
            if (error) {
                console.log('몽고디비 연결 에러', error);
            } else {
                console.log('몽고디비 연결 성공');
            }
        });
    };
    connect();
    mongoose.connection.on('error', (error) => {
        console.error('몽고디비 연결 에러', error);
    });
    mongoose.connection.on('disconnected', () => {
Kim, Subin's avatar
Kim, Subin committed
23
        console.error('몽고디비 연결이 끊겼습니다. 연결을 재시도합니다.');
Ha YeaJin's avatar
pages    
Ha YeaJin committed
24
25
        connect();
    });
Kim, Subin's avatar
Kim, Subin committed
26

Ha YeaJin's avatar
pages    
Ha YeaJin committed
27
28
29
    require('./user');
    require('./reserve');
};