import mongoose from "mongoose";

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;
}