Skip to content

Commit

Permalink
Update: Fixed empty state of notes and trms
Browse files Browse the repository at this point in the history
  • Loading branch information
Basi-mohd committed Nov 17, 2024
1 parent f82b1ab commit 5e40bbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions server/src/controllers/note.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 5e40bbf

Please sign in to comment.