mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
16 lines
427 B
JavaScript
16 lines
427 B
JavaScript
import mongoose from 'mongoose';
|
|
import config from '../config.js';
|
|
|
|
export default (req, res, next)=>{
|
|
// Bypass DB checks during testing
|
|
if(config.get('node_env') == 'test') return next();
|
|
|
|
if(mongoose.connection.readyState == 1) return next();
|
|
throw {
|
|
HBErrorCode : 13,
|
|
name : 'Database Connection Error',
|
|
message : 'Unable to connect to database',
|
|
status : mongoose.connection.readyState
|
|
};
|
|
};
|