2
0

fix: 🚑️ Webhook and instant updates

This commit is contained in:
Baptiste Arnaud
2022-02-22 10:16:35 +01:00
parent 642a42779b
commit d49461cde6
36 changed files with 317 additions and 204 deletions

View File

@ -12,7 +12,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const id = req.query.id.toString()
if (req.method === 'PUT') {
const data = JSON.parse(req.body)
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
const typebots = await prisma.user.update({
where: { id },
data,

View File

@ -23,7 +23,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
return res.send({ credentials })
}
if (req.method === 'POST') {
const data = JSON.parse(req.body) as Omit<Credentials, 'ownerId'>
const data = (
typeof req.body === 'string' ? JSON.parse(req.body) : req.body
) as Omit<Credentials, 'ownerId'>
const { encryptedData, iv } = encrypt(data.data)
const credentials = await prisma.credentials.create({
data: {

View File

@ -22,7 +22,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
return res.send({ customDomains })
}
if (req.method === 'POST') {
const data = JSON.parse(req.body) as Omit<CustomDomain, 'ownerId'>
const data = (
typeof req.body === 'string' ? JSON.parse(req.body) : req.body
) as Omit<CustomDomain, 'ownerId'>
try {
await createDomainOnVercel(data.name)
} catch (err) {