Skip to content

Commit bbf9bff

Browse files
committed
Api for user iams
1 parent c9f0b0a commit bbf9bff

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ app.use(express.json())
2626

2727
if (!inProduction) app.use(accessLogger)
2828

29-
app.get('/ping', (_req, res) => {
30-
res.send('pong')
31-
})
29+
app.get('/ping', (_req, res) => res.send('pong'))
3230

3331
app.post('/', (req, res) => {
3432
const { userId, iamGroups = [] } = req.body
@@ -45,7 +43,7 @@ app.post('/', (req, res) => {
4543
if (Object.keys(access).length !== 0)
4644
logger.info('IAM authentication', { userId, iamGroups, access })
4745

48-
res.send(access)
46+
return res.send(access)
4947
})
5048

5149
app.get('/access-to-all', (_req, res) => {
@@ -55,11 +53,19 @@ app.get('/access-to-all', (_req, res) => {
5553
access[org] = { read: true, write: true, admin: true }
5654
})
5755

58-
res.send(access)
56+
return res.send(access)
5957
})
6058

61-
app.get('/organisation-data', (_req, res) => {
62-
res.send(data)
59+
app.get('/organisation-data', (_req, res) => res.send(data))
60+
61+
app.get('/:id', async (req, res) => {
62+
const { id } = req.params
63+
64+
const user = await User.findByPk(id)
65+
66+
if (!user) return res.sendStatus(404)
67+
68+
return res.send(user)
6369
})
6470

6571
app.use(Sentry.Handlers.errorHandler())

0 commit comments

Comments
 (0)