chore: generate

This commit is contained in:
opencode-agent[bot] 2026-06-24 10:09:04 +00:00
parent 05f335ce62
commit fe655b7630
4 changed files with 32 additions and 28 deletions

View File

@ -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 }))
}

View File

@ -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 }))
}

View File

@ -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))
})
})

View File

@ -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<string, { value: string }>).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<string, { value: string }>).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)