Skip to content

Commit

Permalink
feat: users listsing of storylink
Browse files Browse the repository at this point in the history
  • Loading branch information
hossainchisty committed Aug 31, 2023
1 parent 1aaaa02 commit d1b8887
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions controllers/userController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Basic Lib Import
const User = require("../models/userModel");
const asyncHandler = require("express-async-handler");
const verifyAuthorization = require("../utility/verifyAuthorization");

Expand All @@ -23,6 +24,28 @@ const getMe = asyncHandler(async (req, res) => {
}
});

/**
* @desc Get all user data
* @route /api/v1/users/list
* @method GET
* @access Private
*/

const userList = asyncHandler(async (req, res) => {
try {
const users = await User.find();
res.status(200).json(users);
} catch (error) {
res.status(500).json({
status: 500,
error: error.message,
message: "Internal Server Error",
});
}
});


module.exports = {
getMe,
userList,
};
3 changes: 2 additions & 1 deletion routes/userRouters.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const {
emailVerify,
} = require("../controllers/authController");

const { getMe } = require("../controllers/userController");
const { getMe, userList } = require("../controllers/userController");

const { protect } = require("../middleware/authMiddleware");

// Routing Implement
router.get("/list", userList);
router.post("/register", createAccountLimiter, registerUser);
router.post("/verify", emailVerify);
router.post("/login", bruteforce.prevent, loginUser);
Expand Down

0 comments on commit d1b8887

Please sign in to comment.