diff --git a/packages/console/app/src/routes/api/support/actions/create-referral.ts b/packages/console/app/src/routes/api/support/actions/create-referral.ts index 02ae38da2..ac4d107be 100644 --- a/packages/console/app/src/routes/api/support/actions/create-referral.ts +++ b/packages/console/app/src/routes/api/support/actions/create-referral.ts @@ -20,7 +20,5 @@ export async function POST(event: APIEvent) { } return Referral.create(body.data) .then((result) => Response.json({ success: true, message: "Referral created", result })) - .catch((error) => - Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }), - ) + .catch((error) => Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 })) } diff --git a/packages/console/app/src/routes/api/support/actions/delete-account.ts b/packages/console/app/src/routes/api/support/actions/delete-account.ts index 7a8b5cee0..a713107df 100644 --- a/packages/console/app/src/routes/api/support/actions/delete-account.ts +++ b/packages/console/app/src/routes/api/support/actions/delete-account.ts @@ -17,7 +17,5 @@ export async function DELETE(event: APIEvent) { } return Account.remove(body.data.email) .then(() => Response.json({ success: true, message: "Account deleted" })) - .catch((error) => - Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }), - ) + .catch((error) => Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 })) } diff --git a/packages/console/core/src/account.ts b/packages/console/core/src/account.ts index 27fb1149b..36098f5ba 100644 --- a/packages/console/core/src/account.ts +++ b/packages/console/core/src/account.ts @@ -38,25 +38,35 @@ export namespace Account { .select({ email: AuthTable.subject }) .from(AuthTable) .where(and(eq(AuthTable.accountID, account.id), eq(AuthTable.provider, "email"))) - const users = await tx - .select({ id: UserTable.id }) - .from(UserTable) - .where(eq(UserTable.accountID, account.id)) + const users = await tx.select({ id: UserTable.id }).from(UserTable).where(eq(UserTable.accountID, account.id)) if (users.length > 0) { await tx .update(KeyTable) .set({ timeDeleted: sql`now()` }) - .where(inArray(KeyTable.userID, users.map((user) => user.id))) + .where( + inArray( + KeyTable.userID, + users.map((user) => user.id), + ), + ) } await tx .update(UserTable) .set({ accountID: null, email: null, name: "", timeDeleted: sql`now()` }) .where(eq(UserTable.accountID, account.id)) if (emails.length > 0) { - await tx.delete(CouponTable).where(inArray(CouponTable.email, emails.map((row) => row.email))) + await tx.delete(CouponTable).where( + inArray( + CouponTable.email, + emails.map((row) => row.email), + ), + ) } await tx.delete(AuthTable).where(eq(AuthTable.accountID, account.id)) - await tx.update(AccountTable).set({ timeDeleted: sql`now()` }).where(eq(AccountTable.id, account.id)) + await tx + .update(AccountTable) + .set({ timeDeleted: sql`now()` }) + .where(eq(AccountTable.id, account.id)) }) }) diff --git a/packages/enterprise/src/routes/api/[...path].ts b/packages/enterprise/src/routes/api/[...path].ts index 39ca8c44d..54c6906d3 100644 --- a/packages/enterprise/src/routes/api/[...path].ts +++ b/packages/enterprise/src/routes/api/[...path].ts @@ -139,22 +139,20 @@ app return c.json({}) }, ) - .post( - "/support/actions/remove-share", - async (c) => { - const authorization = c.req.header("authorization") - const expected = `Bearer ${(Resource as unknown as Record).SUPPORT_API_KEY.value}` - const actual = Buffer.from(authorization ?? "") - const secret = Buffer.from(expected) - if (actual.length !== secret.length || !timingSafeEqual(actual, secret)) return c.json({ error: "Unauthorized" }, 401) + .post("/support/actions/remove-share", async (c) => { + const authorization = c.req.header("authorization") + const expected = `Bearer ${(Resource as unknown as Record).SUPPORT_API_KEY.value}` + const actual = Buffer.from(authorization ?? "") + const secret = Buffer.from(expected) + if (actual.length !== secret.length || !timingSafeEqual(actual, secret)) + return c.json({ error: "Unauthorized" }, 401) - const body = z.object({ shareID: z.string().min(1) }).safeParse(await c.req.json().catch(() => undefined)) - if (!body.success) return c.json({ error: "Invalid request", issues: body.error.issues }, 400) - return Share.removeAdmin({ id: body.data.shareID }) - .then(() => c.json({ success: true, message: "Share removed" })) - .catch((error) => c.json({ error: error instanceof Error ? error.message : String(error) }, 400)) - }, - ) + const body = z.object({ shareID: z.string().min(1) }).safeParse(await c.req.json().catch(() => undefined)) + if (!body.success) return c.json({ error: "Invalid request", issues: body.error.issues }, 400) + return Share.removeAdmin({ id: body.data.shareID }) + .then(() => c.json({ success: true, message: "Share removed" })) + .catch((error) => c.json({ error: error instanceof Error ? error.message : String(error) }, 400)) + }) export function GET(event: APIEvent) { return app.fetch(event.request)