24 lines
760 B
TypeScript
24 lines
760 B
TypeScript
import { withSentry } from '@sentry/nextjs'
|
|
import prisma from 'libs/prisma'
|
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
import { getAuthenticatedUser } from 'services/api/utils'
|
|
import { methodNotAllowed, notAuthenticated } from 'utils/api'
|
|
|
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
const user = await getAuthenticatedUser(req)
|
|
if (!user) return notAuthenticated(res)
|
|
|
|
const id = req.query.userId as string
|
|
if (req.method === 'PUT') {
|
|
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
|
|
const typebots = await prisma.user.update({
|
|
where: { id },
|
|
data,
|
|
})
|
|
return res.send({ typebots })
|
|
}
|
|
return methodNotAllowed(res)
|
|
}
|
|
|
|
export default withSentry(handler)
|