Added suspension mechanism.
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
export function needDatabase(res, req, next) {
|
||||
if (mongoose.connection.readyState != 1) {
|
||||
export function needDatabase(req, res, next) {
|
||||
if (checkDatabaseConnection()) {
|
||||
res.status(500).send("Internal server error: Database connection faulty.");
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
export function checkDatabaseConnection() {
|
||||
return mongoose.connection.readyState == 1;
|
||||
}
|
||||
Reference in New Issue
Block a user