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(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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue