Skip to content
Snippets Groups Projects
Commit 089cc203 authored by Ahmad, Rezwan (PG/T - Comp Sci & Elec Eng)'s avatar Ahmad, Rezwan (PG/T - Comp Sci & Elec Eng)
Browse files

GET -> getUser added

parent 4997f796
No related branches found
No related tags found
1 merge request!9Create endpoint for user-registration
......@@ -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')
}
......@@ -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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment