(params: {
userId: string
logger: Logger
})
| 586 | // --------------------------------------------------------------------------- |
| 587 | |
| 588 | export async function getActiveSubscription(params: { |
| 589 | userId: string |
| 590 | logger: Logger |
| 591 | }): Promise<SubscriptionRow | null> { |
| 592 | const { userId } = params |
| 593 | |
| 594 | const subs = await db |
| 595 | .select() |
| 596 | .from(schema.subscription) |
| 597 | .where( |
| 598 | and( |
| 599 | eq(schema.subscription.user_id, userId), |
| 600 | eq(schema.subscription.status, 'active'), |
| 601 | ), |
| 602 | ) |
| 603 | .orderBy(desc(schema.subscription.updated_at)) |
| 604 | .limit(1) |
| 605 | |
| 606 | return subs[0] ?? null |
| 607 | } |
| 608 | |
| 609 | export async function isSubscriber(params: { |
| 610 | userId: string |
no test coverage detected