diff --git a/server/storages/file.js b/server/storages/file.js index 9fc22ccd..ae5f6abc 100644 --- a/server/storages/file.js +++ b/server/storages/file.js @@ -10,6 +10,9 @@ module.exports = async function(params) { getUserById: async function(id) { return users.find(user => user.id === id) }, + getUsersByIds: async function(ids) { + return users.filter(user => ids.find(id => user.id === id)) + }, getUserByEmail: async function(email) { return users.find(user => user.email === email) }, diff --git a/server/users.js b/server/users.js index b7d69e62..10b002f6 100644 --- a/server/users.js +++ b/server/users.js @@ -3,6 +3,18 @@ const jwtMiddleware = require('./jwt').jwtMiddleware let router = express.Router() +// Get the list of users +router.get('', jwtMiddleware, async function(req, res, next) { + let users = [] + if (!req.query || req.query['ids']) { + users = await req.app.get('storage').getUsersByIds(req.query['ids'].split(',')) + } + res.json({ + results: users, + count: users.length + }) +}) + router.get('/:userId', jwtMiddleware, async (req, res, next) => { if (req.user.id !== req.params.userId) return res.sendStatus(403) const user = await req.app.get('storage').getUserById(req.params.userId)