| 210 | } |
| 211 | |
| 212 | export async function deleteProject( |
| 213 | request: FastifyRequest<{ Params: { id: string } }>, |
| 214 | reply: FastifyReply |
| 215 | ) { |
| 216 | const project = await db.project.findFirst({ |
| 217 | where: { |
| 218 | id: request.params.id, |
| 219 | organizationId: request.client!.organizationId, |
| 220 | }, |
| 221 | }); |
| 222 | |
| 223 | if (!project) { |
| 224 | throw new HttpError('Project not found', { status: 404 }); |
| 225 | } |
| 226 | |
| 227 | await db.project.update({ |
| 228 | where: { |
| 229 | id: request.params.id, |
| 230 | }, |
| 231 | data: { |
| 232 | deleteAt: new Date(Date.now() + 24 * 60 * 60 * 1000), |
| 233 | }, |
| 234 | }); |
| 235 | |
| 236 | await getProjectByIdCached.clear(request.params.id); |
| 237 | |
| 238 | reply.send({ success: true }); |
| 239 | } |
| 240 | |
| 241 | // Clients CRUD |
| 242 | export async function listClients( |