From 0ff117ba0cbaf69c7d6abe1d82cc21e9819a2b72 Mon Sep 17 00:00:00 2001 From: Baptiste CERDAN <baptiste.owenia@gmail.com> Date: Thu, 16 Dec 2021 09:34:03 +0100 Subject: [PATCH] :sparkles: add students list on API --- README.md | 4 +++- backend/routes/auth.js | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8447098..5aab95c 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,13 @@ Features the following REST endpoints: - **/api/login** -- **/api/pay_adhesion** +- **/api/pay_adhesion** (POST) body : {"student_number" : 12345678} - **/api/me** - **/api/me/update** +- **/api/etudiants** (GET) + ## Development - Run `npm start`, server will run at `http://localhost:8005` and MongoDB `http://localhost:27017` diff --git a/backend/routes/auth.js b/backend/routes/auth.js index a4fa60e..408b343 100644 --- a/backend/routes/auth.js +++ b/backend/routes/auth.js @@ -141,4 +141,9 @@ router.post('/me/update', passport.authenticate('jwt', {session: false}), async res.status(200).json(); }); +router.get('/etudiants', async (req, res) => { + const users = await User.find(); + return res.status(200).json(users); +}); + module.exports = router; -- GitLab