From 5e40bbfa36e0176b51d88d969dc273727a33e739 Mon Sep 17 00:00:00 2001 From: Basim Mohammed Date: Sun, 17 Nov 2024 15:05:08 +0530 Subject: [PATCH] Update: Fixed empty state of notes and trms --- server/src/controllers/note.controller.ts | 8 ++++++++ server/src/index.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/controllers/note.controller.ts b/server/src/controllers/note.controller.ts index 5b2751d5..ac0b8a7b 100644 --- a/server/src/controllers/note.controller.ts +++ b/server/src/controllers/note.controller.ts @@ -102,6 +102,14 @@ export const deleteNote = async (req: Request, res: Response, next: NextFunction export const getNote = async (req: Request, res: Response, next: NextFunction) => { try { const notes = await Notes.findOne(); + if(!notes){ + const emptyNote = { + customerNotes: [], + termsAndConditions: [] + }; + const newNotes = await Notes.create(emptyNote); + return res.status(200).json(newNotes); + } if (notes) { return res.status(200).json(notes); diff --git a/server/src/index.ts b/server/src/index.ts index e09f86ec..55574448 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -72,7 +72,7 @@ let mongoUrl = `mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD if (process.env.USE_MONGOATLAS === 'true') { mongoUrl = process.env.MONGODB_ATLAS_URL as string; } -console.log(mongoUrl,'mongoUrl'); + mongoose .connect(mongoUrl) .then(() => {