diff --git a/app/models.js b/app/models.js index 741af6537..61a03bb66 100644 --- a/app/models.js +++ b/app/models.js @@ -5,6 +5,13 @@ const { USER_PERFORMANCE } = require('./data') + +/** + * @description Retrieve all users + * @returns {Array} All users + */ +const getAllUsers = () => USER_MAIN_DATA + /** * @description Retrieve the main user info (first name, last name, today score) * @param {number} id @@ -38,6 +45,7 @@ const getUserPerformance = id => USER_PERFORMANCE .shift() module.exports = { + getAllUsers, getUserById, getUserActivityById, getUserAverageSession, diff --git a/app/routes.js b/app/routes.js index e3d9161a2..1c17ae451 100644 --- a/app/routes.js +++ b/app/routes.js @@ -4,6 +4,7 @@ const idx = require('idx') const router = express.Router() const { + getAllUsers, getUserById, getUserActivityById, getUserAverageSession, @@ -15,6 +16,11 @@ const { } = require('./middleware') +router.get('/users', (req, res) => { + const allUsers = getAllUsers() + return res.json(allUsers) +}) + router.get('/user/:id', (req, res) => { const userId = idx(req, _ => _.params.id) const userData = getUserById(Number(userId))