2
0
Files
bot/apps/viewer/pages/api/users/me.ts
2022-09-27 08:30:42 +02:00

18 lines
604 B
TypeScript

import { withSentry } from '@sentry/nextjs'
import { NextApiRequest, NextApiResponse } from 'next'
import { authenticateUser } from 'services/api/utils'
import { isNotDefined } from 'utils'
import { methodNotAllowed } from 'utils/api'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'GET') {
const user = await authenticateUser(req)
if (isNotDefined(user))
return res.status(404).send({ message: 'User not found' })
return res.send({ id: user.id, email: user.email })
}
return methodNotAllowed(res)
}
export default withSentry(handler)