From 841cab36da1e9e406560255de8342f36a9c60aec Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 9 Jul 2022 18:30:44 +0200 Subject: [PATCH] Updated the user route --- routes/user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/user.js b/routes/user.js index 48ef33a..8c1980c 100644 --- a/routes/user.js +++ b/routes/user.js @@ -2,7 +2,7 @@ const app = require('express').Router(); const rateLimit = require('express-rate-limit'); const {validateSchema} = require('../util/validate'); const {createUser, updateUser, updateSocials} = require('../validations/user'); -const {getUserByName, createAccount, updateAccount, updateUserSocials} = require('../controller/user'); +const {getUserByName, createAccount, updateAccount, updateUserSocials, getUser} = require('../controller/user'); const {isAuthenticatedUser} = require('../middlewares/authenticate'); // Defines the rate limit to create a new account @@ -53,9 +53,9 @@ app.patch("/socials", isAuthenticatedUser, async (req, res) => { res.json({message: "Your changes were successfully applied"}); }); -// Gets a specific user by name -app.get("/:username", async (req, res) => { - const user = await getUserByName(req.params.username); +// Gets a specific user by name or id +app.get("/:user", async (req, res) => { + let user = await getUser(req.params.user); if (user === null) return res.status(404).json({message: "The provided user does not exist"}); user.password = undefined user.__v = undefined