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(() => {