feat: update getHotel to use real hotel api endpoint, support for service tokens, type modifications

This commit is contained in:
Chuma McPhoy
2024-07-24 14:27:17 +02:00
parent 7393347f99
commit 1ff6cd267d
14 changed files with 195 additions and 89 deletions

View File

@@ -7,6 +7,7 @@ import {
sessionExpiredError,
unauthorizedError,
} from "./errors/trpc"
import { getAuthToken } from "./tokenManager"
import { transformer } from "./transformer"
import { langInput } from "./utils"
@@ -99,3 +100,17 @@ export const safeProtectedProcedure = t.procedure.use(async function (opts) {
},
})
})
export const anonymousOrAuthProcedure = t.procedure.use(async function (opts) {
const session: Session | null = await opts.ctx.auth()
const userToken = session?.token?.access_token || null
const getToken = async () => await getAuthToken(userToken)
return opts.next({
ctx: {
session,
getToken,
},
})
})