All files / database connector.ts

90% Statements 9/10
100% Branches 0/0
66.67% Functions 2/3
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 142x 2x   2x 2x 2x 2x   2x 2x     2x  
import * as mongoose from 'mongoose';
import * as bluebird from 'bluebird';
 
export function connect(uri: string) {
    (<any>mongoose).Promise = bluebird;
    mongoose.connect(uri).then(() => {
        console.log('success connected to', uri);
    });
    const db = mongoose.connection;
    db.on('error', (err: any) => {
        throw new Error('unable to connect to database at ' + uri + err);
    });
    return db;
}