feat(editor): ✨ Team workspaces
This commit is contained in:
25
apps/builder/pages/api/credentials/[credentialsId].ts
Normal file
25
apps/builder/pages/api/credentials/[credentialsId].ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { withSentry } from '@sentry/nextjs'
|
||||
import prisma from 'libs/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from 'services/api/utils'
|
||||
import { badRequest, methodNotAllowed, notAuthenticated } from 'utils'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const user = await getAuthenticatedUser(req)
|
||||
if (!user) return notAuthenticated(res)
|
||||
const workspaceId = req.query.workspaceId as string | undefined
|
||||
if (!workspaceId) return badRequest(res)
|
||||
if (req.method === 'DELETE') {
|
||||
const credentialsId = req.query.credentialsId.toString()
|
||||
const credentials = await prisma.credentials.deleteMany({
|
||||
where: {
|
||||
id: credentialsId,
|
||||
workspace: { id: workspaceId, members: { some: { userId: user.id } } },
|
||||
},
|
||||
})
|
||||
return res.send({ credentials })
|
||||
}
|
||||
return methodNotAllowed(res)
|
||||
}
|
||||
|
||||
export default withSentry(handler)
|
Reference in New Issue
Block a user