diff --git a/daily-thought-user-service/server/controllers/appController.js b/daily-thought-user-service/server/controllers/appController.js index fcb989a9cbb26ef61d21ba383e3af741192c90fb..8936ad6a96875dfd189dffa8a5d112d1b1ed5ce1 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 df787b2e06278e66d8f9c9d149f60189efbdcea6..66abc171dcb1106e40bdc89ec0d66367fb2d4b93 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 b32661132209530b8003db330748fb0e566d60e1..42c2de1cee354e304212ebf83842fdb6093239d0 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