From 089cc203f13f2b3d47f2fc037e0d3d45fc7008c1 Mon Sep 17 00:00:00 2001
From: Shaikh Rezwan Rafid Ahmad <sa03267@surrey.ac.uk>
Date: Fri, 17 Mar 2023 15:53:23 +0000
Subject: [PATCH] GET -> getUser added

---
 .../server/controllers/appController.js              | 12 +++++++++---
 .../server/model/User.model.js                       |  2 ++
 daily-thought-user-service/server/router/route.js    |  5 ++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/daily-thought-user-service/server/controllers/appController.js b/daily-thought-user-service/server/controllers/appController.js
index fcb989a9..8936ad6a 100644
--- a/daily-thought-user-service/server/controllers/appController.js
+++ b/daily-thought-user-service/server/controllers/appController.js
@@ -3,7 +3,6 @@ import bcrypt from 'bcrypt';
 import jwt from 'jsonwebtoken';
 import ENV from '../config.js'
 
-
 // Middleware
 export async function verifyUser(req,res, next){
 
@@ -22,7 +21,6 @@ export async function verifyUser(req,res, next){
     }
 }
 
-
 /** POST: http://localhost:8080/api/register
  * @param : {
   "username" : "example123",
@@ -114,6 +112,7 @@ export async function login(req,res){
                                         username : user.username
                                     }, ENV.JWT_SECRET , { expiresIn : "24h"});
 
+
                         return res.status(200).send({
                             msg: "Login Successful...!",
                             username: user.username,
@@ -132,4 +131,11 @@ export async function login(req,res){
     } catch (error) {
         return res.status(500).send({ error});
     }
-}
\ No newline at end of file
+}
+
+export async function getUser(req,res){
+
+    // const { username } = req.params;
+
+    res.json('getUser route')
+}
diff --git a/daily-thought-user-service/server/model/User.model.js b/daily-thought-user-service/server/model/User.model.js
index df787b2e..66abc171 100644
--- a/daily-thought-user-service/server/model/User.model.js
+++ b/daily-thought-user-service/server/model/User.model.js
@@ -16,10 +16,12 @@ export const UserSchema = new mongoose.Schema({
         required : [true, "Please provide a unique email"],
         unique: true,
     },
+
     firstName: { type: String},
     lastName: { type: String},
     mobile : { type : Number},
     profile: { type: String}
+    
 });
 
 export default mongoose.model.Users || mongoose.model('User', UserSchema);
\ No newline at end of file
diff --git a/daily-thought-user-service/server/router/route.js b/daily-thought-user-service/server/router/route.js
index b3266113..42c2de1c 100644
--- a/daily-thought-user-service/server/router/route.js
+++ b/daily-thought-user-service/server/router/route.js
@@ -3,8 +3,11 @@ import * as controller from '../controllers/appController.js';
 
 const router = Router();
 
-// /** POST Methods */
+/** POST Methods */
 router.route('/register').post(controller.register); // Register
 router.route('/login').post(controller.verifyUser, controller.login); // Login
 
+/** GET Methods */
+router.route('/user/:username').get(controller.getUser); // GetUser
+
 export default router;
\ No newline at end of file
-- 
GitLab