From 07ec823c3bcf51d0a5da0dd2dddec4d1f4a694ce Mon Sep 17 00:00:00 2001
From: Alan Chamathil <77508072+AlanChamathil@users.noreply.github.com>
Date: Fri, 31 Mar 2023 13:06:39 +0100
Subject: [PATCH] Re-Dockerised with date being added on the database,
 reconfigured the DotENV files

---
 .env                            | 2 +-
 node_modules/.package-lock.json | 8 ++++++++
 package-lock.json               | 9 +++++++++
 package.json                    | 1 +
 src/index.js                    | 2 +-
 src/routes/notification.js      | 6 +++++-
 6 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/.env b/.env
index 909d9c3..ea7b45a 100644
--- a/.env
+++ b/.env
@@ -1,4 +1,4 @@
-PORT=3001
+PORT= 3001
 MONGODB_URI=mongodb://localhost:27017/notificationapp
 DB_NAME=notificationapp
 NAME=notification-service
\ No newline at end of file
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
index 66b7814..4c6e7d3 100644
--- a/node_modules/.package-lock.json
+++ b/node_modules/.package-lock.json
@@ -229,6 +229,14 @@
         "npm": "1.2.8000 || >= 1.4.16"
       }
     },
+    "node_modules/dotenv": {
+      "version": "16.0.3",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
+      "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
+      "engines": {
+        "node": ">=12"
+      }
+    },
     "node_modules/ee-first": {
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
diff --git a/package-lock.json b/package-lock.json
index 3cba06a..b9f8804 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
       "version": "1.0.0",
       "license": "ISC",
       "dependencies": {
+        "dotenv": "^16.0.3",
         "express": "^4.18.2",
         "mongoose": "^7.0.3",
         "nodemon": "^2.0.22"
@@ -239,6 +240,14 @@
         "npm": "1.2.8000 || >= 1.4.16"
       }
     },
+    "node_modules/dotenv": {
+      "version": "16.0.3",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
+      "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
+      "engines": {
+        "node": ">=12"
+      }
+    },
     "node_modules/ee-first": {
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
diff --git a/package.json b/package.json
index eb14ed1..0115199 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
   "author": "Alan",
   "license": "ISC",
   "dependencies": {
+    "dotenv": "^16.0.3",
     "express": "^4.18.2",
     "mongoose": "^7.0.3",
     "nodemon": "^2.0.22"
diff --git a/src/index.js b/src/index.js
index cd28125..85fef6b 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,6 @@
 // import { MongoClient } from "mongodb";
-// const connectionString = process.env.ATLAS_URI || "";
 require('./db/mongoose');
+require('dotenv').config();
 const express = require('express');
 //const Notification = require('./schema/schema')
 
diff --git a/src/routes/notification.js b/src/routes/notification.js
index fbe6c86..8e37e7e 100644
--- a/src/routes/notification.js
+++ b/src/routes/notification.js
@@ -66,7 +66,11 @@ router.get("/info/:id", async (req,res) =>{
   router.post("/create", async (req,res) => {
     //recieve the notifcation info from the user
     // send the notifcation to the database (create/save/insert methods)
-    const notifications = new Notification(req.body);
+    //const notifications = new Notification(req.body);
+
+    const date = new Date;
+    const notifications = new Notification({ userid: req.body['userid'], title: req.body['title'], description: req.body['description'], date: date });
+
     try{
         await notifications.save();
         res.status(201).send(notifications);
-- 
GitLab