Files
web/apps/partner-sas/lib/trpc.ts
Joakim Jäderberg c46e71d76e Merged in feature/SW-3505-fetch-eurobonus-points (pull request #2847)
feat(SW-3505): add endpoint for getting eurobonus profile

* feat(SW-3505): add endpoint for getting eurobonus profile

* make sure we add loginType to session

* no need to run zod parsing twice

* Make SAS environment variables mandatory


Approved-by: Anton Gunnarsson
2025-09-23 12:13:20 +00:00

40 lines
925 B
TypeScript

import { headers } from "next/headers"
import { createContext } from "@scandic-hotels/trpc/context"
import {
appServerClient,
configureServerClient,
} from "@scandic-hotels/trpc/serverClient"
import { auth } from "@/auth"
import type { Lang } from "@scandic-hotels/common/constants/language"
export async function createAppContext() {
const headersList = await headers()
const ctx = createContext({
lang: headersList.get("x-lang") as Lang,
pathname: headersList.get("x-pathname")!,
uid: headersList.get("x-uid"),
url: headersList.get("x-url")!,
contentType: headersList.get("x-contenttype")!,
auth: async () => {
const session = await auth()
return session
},
})
return ctx
}
export function configureTrpc() {
configureServerClient(createAppContext)
}
export async function serverClient() {
const ctx = await createAppContext()
return appServerClient(ctx)
}