canary probe route for todo-backend

This commit is contained in:
Guy Bianco IV 2021-06-24 15:18:57 -04:00
parent bd4fc626ab
commit 50a3d3af14

View file

@ -17,18 +17,25 @@ app.use(express.json());
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.use(cookieParser()); app.use(cookieParser());
const sequelize = new Sequelize(dbConnectionOptions); let canary = true;
app.get("/", (req, res) => { const sequelize = new Sequelize(dbConnectionOptions);
sequelize sequelize
.authenticate() .authenticate()
.catch((err) => {
console.error("Unable to connect to the database:", err);
res.status(500).send("Unable to connect to the database:" + err);
})
.then(() => { .then(() => {
res.send("OK"); console.log("Connection has been established successfully.");
})
.catch((err) => {
canary = false;
console.error("Unable to connect to the database:", err);
}); });
app.get("/", (req, res) => {
if (canary) {
res.send("OK");
} else {
res.status(500).send("Experienced an error on startup.");
}
}); });
// Add APIs // Add APIs