update readme

This commit is contained in:
Robert Soriano
2022-05-18 07:16:20 -07:00
parent 13385d2bb6
commit 83624e0ca8

View File

@@ -104,12 +104,13 @@ export const router = trpc
The `createContext`-function is called for each incoming request so here you can add contextual information about the calling user from the request object. Learn more about authorization [here](https://trpc.io/docs/authorization).
```ts
// ~/server/trpc/index.ts
import * as trpc from '@trpc/server'
import type { CompatibilityEvent } from 'h3'
import { decodeAndVerifyJwtToken } from '~/somewhere/in/your/app/utils'
// The app's context - is generated for each incoming request
export async function createContext(event: CompatibilityEvent) {
export async function createContext({ req }: CompatibilityEvent) {
// Create your context based on the request object
// Will be available as `ctx` in all your resolvers