mirror of
https://github.com/SrIzan10/api.git
synced 2026-06-06 00:46:48 +00:00
29 lines
710 B
TypeScript
29 lines
710 B
TypeScript
import { prisma } from '../../index.js'
|
|
import type { Handler } from 'express'
|
|
|
|
export const del: Handler = async (req, res) => {
|
|
if (req.query.userid && req.query.key === process.env.SERN_TIME) {
|
|
if (
|
|
await prisma.sern_timezones.findUnique({
|
|
where: { userid: req.query.userid as string },
|
|
})
|
|
)
|
|
return res.status(400).json({
|
|
error: "the user doesn't exist",
|
|
})
|
|
|
|
await prisma.sern_timezones.delete({
|
|
where: {
|
|
userid: req.query.userid as string,
|
|
},
|
|
}).catch(() => {
|
|
return res.status(500).json({ error: 'that didnt work' })
|
|
})
|
|
res.json({ ok: 'done' })
|
|
} else {
|
|
res.status(400).json({
|
|
error: 'make sure you have the userid param and the right key',
|
|
})
|
|
}
|
|
}
|