Merged in feat/sw-2872-dependency-inject-app-context-in-trpc-package (pull request #2478)
feat(SW-2872) Dependency inject app context in trpc package * Move appRouter to trpc package * WIP Move serverClient to trpc package Doesn't handle errors yet * Don't use global * Use trpc everywhere Approved-by: Linus Flood
This commit is contained in:
4
packages/booking-flow/global.d.ts
vendored
Normal file
4
packages/booking-flow/global.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import "@scandic-hotels/common/global.d.ts"
|
||||
import "@scandic-hotels/trpc/types.d.ts"
|
||||
import "@scandic-hotels/trpc/auth.d.ts"
|
||||
import "@scandic-hotels/trpc/jwt.d.ts"
|
||||
@@ -1,13 +1,28 @@
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import { env } from "../env/server"
|
||||
import { serverClient } from "./trpc"
|
||||
|
||||
const tempEnv = env.FOO
|
||||
|
||||
export function Temp() {
|
||||
export async function Temp() {
|
||||
const caller = await serverClient()
|
||||
const destinations = await caller.autocomplete.destinations({
|
||||
lang: Lang.en,
|
||||
includeTypes: ["hotels"],
|
||||
query: "Stockholm",
|
||||
})
|
||||
const hotel = destinations.hits.hotels[0].name
|
||||
|
||||
return (
|
||||
<Typography variant="Body/Lead text">
|
||||
<p>Tjena {tempEnv}</p>
|
||||
</Typography>
|
||||
<div>
|
||||
<Typography variant="Body/Lead text">
|
||||
<p>Tjena {tempEnv}</p>
|
||||
</Typography>
|
||||
<Typography variant="Body/Lead text">
|
||||
<p>Something fetched by tRPC: {hotel}</p>
|
||||
</Typography>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
3
packages/booking-flow/lib/trpc.ts
Normal file
3
packages/booking-flow/lib/trpc.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { packageServerClient } from "@scandic-hotels/trpc/serverClient"
|
||||
|
||||
export const serverClient = packageServerClient
|
||||
Reference in New Issue
Block a user