Toggle navigation
Toggle navigation
This project
Loading...
Sign in
황선혁
/
weather_chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Eric Whale
2022-05-29 18:55:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bb7b429be91b3971538c722560e1c64ee925473c
bb7b429b
1 parent
51b508d0
Add getAllusers api
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
actions/userActions.js
client/src/routes/userroom.jsx
routes/userRoutes.js
actions/userActions.js
View file @
bb7b429
...
...
@@ -69,7 +69,20 @@ const loginUser = asyncHandler(async (req, res) => {
}
});
// @desc Get user(only self)
// @desc Get all users
// @route GET /api/users/all
// @access Public
const
getAllusers
=
asyncHandler
(
async
(
req
,
res
)
=>
{
const
users
=
await
User
.
find
()
.
select
(
"-password"
)
.
select
(
"-updatedAt"
)
.
select
(
"-createdAt"
)
.
select
(
"-email"
);
res
.
status
(
200
).
json
(
users
);
});
// @desc Get user
// @route GET /api/users/self
// @access Private
const
getSelf
=
asyncHandler
(
async
(
req
,
res
)
=>
{
...
...
@@ -79,5 +92,6 @@ const getSelf = asyncHandler(async (req, res) => {
module
.
exports
=
{
signupUser
,
loginUser
,
getAllusers
,
getSelf
,
};
...
...
client/src/routes/userroom.jsx
View file @
bb7b429
...
...
@@ -7,7 +7,7 @@ function Userroom() {
return
(
<
div
>
<
Topbar
/>
<
h1
>
User
room page
</
h1
>
<
h1
>
User
Room
</
h1
>
<
div
>
<
UserBox
/>
<
UserBox
/>
...
...
routes/userRoutes.js
View file @
bb7b429
const
express
=
require
(
"express"
);
const
router
=
express
.
Router
();
const
{
signupUser
,
loginUser
,
getSelf
}
=
require
(
"../actions/userActions"
);
const
{
signupUser
,
loginUser
,
getAllusers
,
getSelf
,
}
=
require
(
"../actions/userActions"
);
const
{
authHandler
}
=
require
(
"../middleware/authMiddleware"
);
router
.
post
(
"/"
,
signupUser
);
router
.
post
(
"/login"
,
loginUser
);
router
.
get
(
"/all"
,
getAllusers
);
router
.
get
(
"/self"
,
authHandler
,
getSelf
);
module
.
exports
=
router
;
...
...
Please
register
or
login
to post a comment