(securityId: string)
| 58 | }; |
| 59 | |
| 60 | export const deleteSecurityById = async (securityId: string) => { |
| 61 | try { |
| 62 | const result = await db |
| 63 | .delete(security) |
| 64 | .where(eq(security.securityId, securityId)) |
| 65 | .returning() |
| 66 | .then((res) => res[0]); |
| 67 | |
| 68 | if (!result) { |
| 69 | throw new TRPCError({ |
| 70 | code: "NOT_FOUND", |
| 71 | message: "Security not found", |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | const application = await findApplicationById(result.applicationId); |
| 76 | |
| 77 | await removeSecurityMiddleware(application, result); |
| 78 | return result; |
| 79 | } catch (error) { |
| 80 | const message = |
| 81 | error instanceof Error ? error.message : "Error removing this security"; |
| 82 | throw new TRPCError({ |
| 83 | code: "BAD_REQUEST", |
| 84 | message, |
| 85 | }); |
| 86 | } |
| 87 | }; |
| 88 | |
| 89 | export const updateSecurityById = async ( |
| 90 | securityId: string, |
no test coverage detected