canary probe route for todo-backend
This commit is contained in:
parent
bd4fc626ab
commit
50a3d3af14
1 changed files with 16 additions and 9 deletions
|
|
@ -17,18 +17,25 @@ app.use(express.json());
|
|||
app.use(express.urlencoded({ extended: true }));
|
||||
app.use(cookieParser());
|
||||
|
||||
let canary = true;
|
||||
|
||||
const sequelize = new Sequelize(dbConnectionOptions);
|
||||
sequelize
|
||||
.authenticate()
|
||||
.then(() => {
|
||||
console.log("Connection has been established successfully.");
|
||||
})
|
||||
.catch((err) => {
|
||||
canary = false;
|
||||
console.error("Unable to connect to the database:", err);
|
||||
});
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
sequelize
|
||||
.authenticate()
|
||||
.catch((err) => {
|
||||
console.error("Unable to connect to the database:", err);
|
||||
res.status(500).send("Unable to connect to the database:" + err);
|
||||
})
|
||||
.then(() => {
|
||||
res.send("OK");
|
||||
});
|
||||
if (canary) {
|
||||
res.send("OK");
|
||||
} else {
|
||||
res.status(500).send("Experienced an error on startup.");
|
||||
}
|
||||
});
|
||||
|
||||
// Add APIs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue