import { authOptions } from '@/config/auth'; import { type BaseService } from '@repo/graphql/api/base'; import { getServerSession } from 'next-auth'; export function useService(service: T) { return async function () { const session = await getServerSession(authOptions); if (!session?.user?.telegramId) throw new Error('Unauthorized'); const customer = { telegramId: session.user.telegramId }; return new service(customer) as InstanceType; }; }