2
0
Files
bot/apps/viewer/pages/api/results/[id].ts
2022-02-22 10:27:31 +01:00

22 lines
624 B
TypeScript

import { withSentry } from '@sentry/nextjs'
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'PATCH') {
const data = (
typeof req.body === 'string' ? JSON.parse(req.body) : req.body
) as { isCompleted: true }
const id = req.query.id.toString()
const result = await prisma.result.update({
where: { id },
data,
})
return res.send(result)
}
return methodNotAllowed(res)
}
export default withSentry(handler)