mirror of
https://github.com/dsoaress/link-free.git
synced 2026-08-17 15:06:06 +01:00
feat: add user management section
This commit is contained in:
23
src/api/data/updateData.ts
Normal file
23
src/api/data/updateData.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { prisma } from 'services/prisma'
|
||||
import { ExceptionError } from 'utils/error'
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
export async function updateData(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { data } = req.body
|
||||
|
||||
if (!data) {
|
||||
throw new ExceptionError('No data provided')
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await prisma.data.update({
|
||||
where: { id: 1 },
|
||||
data: { data: JSON.stringify(req.body.data) }
|
||||
})
|
||||
|
||||
res.status(200).json(response)
|
||||
} catch (err: any) {
|
||||
throw new ExceptionError(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user