Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I_Helmet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 62
I_Helmet
Commits
9259f210
Commit
9259f210
authored
Apr 30, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search User API
parent
eb3d178e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
+28
-4
IT18021080/Telemedicine-Chat-App/backend/controllers/userControllers.js
...emedicine-Chat-App/backend/controllers/userControllers.js
+23
-1
IT18021080/Telemedicine-Chat-App/backend/routes/userRoutes.js
...021080/Telemedicine-Chat-App/backend/routes/userRoutes.js
+5
-3
No files found.
IT18021080/Telemedicine-Chat-App/backend/controllers/userControllers.js
View file @
9259f210
...
@@ -63,4 +63,26 @@ const authUser = asyncHandler(async (req, res) => {
...
@@ -63,4 +63,26 @@ const authUser = asyncHandler(async (req, res) => {
}
}
});
});
module
.
exports
=
{
registerUser
,
authUser
};
// /api/user?search = minosh - goint to creat search query
\ No newline at end of file
//This is how to access the query (search query)
const
allUsers
=
asyncHandler
(
async
(
req
,
res
)
=>
{
const
keyword
=
req
.
query
.
search
?
{
//use $or operation
$or
:
[
//references from MongoDB pages.can get more information from that about $regex
{
name
:
{
$regex
:
req
.
query
.
search
,
$options
:
"
i
"
}
},
{
email
:
{
$regex
:
req
.
query
.
search
,
$options
:
"
i
"
}
},
],
}
:
{};
//query write to database
const
users
=
await
(
await
User
.
find
(
keyword
));
//.find({ _id: { $ne: req.user._id } });
// find({_id:{$ne:req.user._id}}) - current id user loged in
res
.
send
(
users
);
//to return
});
module
.
exports
=
{
registerUser
,
authUser
,
allUsers
};
\ No newline at end of file
IT18021080/Telemedicine-Chat-App/backend/routes/userRoutes.js
View file @
9259f210
const
express
=
require
(
"
express
"
);
const
express
=
require
(
"
express
"
);
const
{
registerUser
,
authUser
}
=
require
(
"
../controllers/userControllers
"
);
const
{
registerUser
,
authUser
,
allUsers
}
=
require
(
"
../controllers/userControllers
"
);
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
router
.
route
(
"
/
"
).
post
(
registerUser
);
router
.
route
(
"
/
"
).
post
(
registerUser
).
get
(
allUsers
);
//User searching API end point
router
.
post
(
"
/login
"
,
authUser
);
router
.
post
(
"
/login
"
,
authUser
);
module
.
exports
=
router
;
module
.
exports
=
router
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment