Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Daily Thought App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COM3014-Coursework
Daily Thought App
Commits
85fdafbe
Commit
85fdafbe
authored
2 years ago
by
Ahmad, Rezwan (PG/T - Comp Sci & Elec Eng)
Browse files
Options
Downloads
Patches
Plain Diff
Update User Implemented
parent
9af8a485
No related branches found
Branches containing commit
No related tags found
1 merge request
!9
Create endpoint for user-registration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daily-thought-user-service/server/controllers/appController.js
+37
-0
37 additions, 0 deletions
...-thought-user-service/server/controllers/appController.js
daily-thought-user-service/server/router/route.js
+4
-0
4 additions, 0 deletions
daily-thought-user-service/server/router/route.js
with
41 additions
and
0 deletions
daily-thought-user-service/server/controllers/appController.js
+
37
−
0
View file @
85fdafbe
...
...
@@ -133,6 +133,7 @@ export async function login(req,res){
}
}
export
async
function
getUser
(
req
,
res
){
const
{
username
}
=
req
.
params
;
...
...
@@ -154,3 +155,39 @@ export async function getUser(req,res){
return
res
.
status
(
404
).
send
({
error
:
"
Cannot find User Data
"
});
}
}
/** PUT: http://localhost:8080/api/updateuser
*
. * @param: {
"header" : "<token>"
}
body: {
firstName: '',
address : '',
profile : ''
}
*/
export
async
function
updateUser
(
req
,
res
){
try
{
const
id
=
req
.
query
.
id
;
if
(
id
){
const
body
=
req
.
body
;
// update the data
UserModel
.
updateOne
({
_id
:
id
},
body
,
function
(
err
,
data
){
if
(
err
)
throw
err
;
return
res
.
status
(
201
).
send
({
msg
:
"
Record Updated...!
"
});
})
}
else
{
return
res
.
status
(
401
).
send
({
error
:
"
User Not Found...!
"
});
}
}
catch
(
error
)
{
return
res
.
status
(
401
).
send
({
error
});
}
}
This diff is collapsed.
Click to expand it.
daily-thought-user-service/server/router/route.js
+
4
−
0
View file @
85fdafbe
...
...
@@ -10,4 +10,8 @@ router.route('/login').post(controller.verifyUser, controller.login); // Login
/** GET Methods */
router
.
route
(
'
/user/:username
'
).
get
(
controller
.
getUser
);
// GetUser
/** PUT Methods */
router
.
route
(
'
/updateuser
'
).
put
(
controller
.
updateUser
);
// is use to update the user profile
export
default
router
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment