From bd4fc626ab266066616bc96bbe6584907d75ad1b Mon Sep 17 00:00:00 2001 From: Guy Bianco IV Date: Thu, 24 Jun 2021 14:06:34 -0400 Subject: [PATCH] improve probe route for todo-backend --- todo-backend/src/Server.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/todo-backend/src/Server.ts b/todo-backend/src/Server.ts index c6dd9a1..e367f58 100644 --- a/todo-backend/src/Server.ts +++ b/todo-backend/src/Server.ts @@ -18,17 +18,17 @@ app.use(express.urlencoded({ extended: true })); app.use(cookieParser()); const sequelize = new Sequelize(dbConnectionOptions); -sequelize - .authenticate() - .then(() => { - console.log("Connection has been established successfully."); - }) - .catch((err) => { - console.error("Unable to connect to the database:", err); - }); app.get("/", (req, res) => { - res.send("OK"); + 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"); + }); }); // Add APIs