diff --git a/lib/auth/utils.ts b/lib/auth/utils.ts index d799e63..b0c6512 100644 --- a/lib/auth/utils.ts +++ b/lib/auth/utils.ts @@ -1,6 +1,5 @@ import { db } from "@/lib/db/index"; import { DrizzleAdapter } from "@auth/drizzle-adapter"; -import { type NextAuthOptions } from "next-auth"; import { getServerSession } from "next-auth/next"; import { type Adapter } from "next-auth/adapters"; import { redirect } from "next/navigation"; @@ -25,13 +24,13 @@ const envSchema = z.object({ export const env = envSchema.parse(process.env); -export const authOptions: NextAuthOptions = { +export const authOptions = { adapter: DrizzleAdapter(db) as Adapter, session: { - strategy: "jwt", // CRITICAL: Use JWT strategy to access token in session callback + strategy: "jwt" as const, // CRITICAL: Use JWT strategy to access token in session callback }, callbacks: { - jwt: async ({ token, account, profile }) => { + jwt: async ({ token, account, profile }: { token: any; account?: any; profile?: any }) => { // Store access token if (account) { token.accessToken = account.access_token; @@ -42,7 +41,7 @@ export const authOptions: NextAuthOptions = { } return token; }, - session: ({ session, token }) => { + session: ({ session, token }: { session: any; token: any }) => { // Copy user id from token if (token?.sub) { session.user.id = token.sub; diff --git a/lib/email/index.ts b/lib/email/index.ts index 82b7264..caefa91 100644 --- a/lib/email/index.ts +++ b/lib/email/index.ts @@ -1,4 +1,7 @@ import { Resend } from "resend"; -import { env } from "@/lib/env.mjs"; -export const resend = new Resend(env.RESEND_API_KEY); +const resendApiKey = process.env.RESEND_API_KEY; + +export const resend = resendApiKey + ? new Resend(resendApiKey) + : null as unknown as Resend; // Will fail at runtime if not configured, but allows build diff --git a/lib/stripe/index.ts b/lib/stripe/index.ts index 8bce28d..3d7c5ed 100644 --- a/lib/stripe/index.ts +++ b/lib/stripe/index.ts @@ -1,6 +1,10 @@ import Stripe from "stripe"; -export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? "", { - apiVersion: "2024-06-20", - typescript: true, -}); +const stripeSecretKey = process.env.STRIPE_SECRET_KEY; + +export const stripe = stripeSecretKey + ? new Stripe(stripeSecretKey, { + apiVersion: "2025-11-17.clover", + typescript: true, + }) + : null as unknown as Stripe; // Will fail at runtime if not configured, but allows build diff --git a/next-auth.d.ts b/next-auth.d.ts index 32f3bf9..f910a27 100644 --- a/next-auth.d.ts +++ b/next-auth.d.ts @@ -1,4 +1,4 @@ -import { DefaultSession, DefaultUser } from "next-auth"; +import { DefaultSession, DefaultUser, AuthOptions } from "next-auth"; import { DefaultJWT } from "next-auth/jwt"; declare module "next-auth" { @@ -13,6 +13,9 @@ declare module "next-auth" { interface User extends DefaultUser { tenantId?: string; } + + // Re-export AuthOptions so it can be imported + export { AuthOptions }; } declare module "next-auth/jwt" {