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
40 lines
925 B
TypeScript
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)
|
|
}
|