mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-26 02:08:40 +02:00
Implement setup task for worker admin environment and add new database schema and snapshot files
This commit is contained in:
@@ -508,3 +508,23 @@ export function formatBytes(bytes: number): string {
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user has an active subscription (server-side only)
|
||||
*/
|
||||
export async function hasActiveSubscription(userId: string): Promise<boolean> {
|
||||
const database = db()
|
||||
|
||||
const [subscription] = await database
|
||||
.select()
|
||||
.from(stripe_subscriptions)
|
||||
.where(
|
||||
and(
|
||||
eq(stripe_subscriptions.user_id, userId),
|
||||
eq(stripe_subscriptions.status, "active")
|
||||
)
|
||||
)
|
||||
.limit(1)
|
||||
|
||||
return !!subscription
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user