mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-02-01 12:47:55 +01:00
update readme
This commit is contained in:
@@ -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).
|
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
|
```ts
|
||||||
|
// ~/server/trpc/index.ts
|
||||||
import * as trpc from '@trpc/server'
|
import * as trpc from '@trpc/server'
|
||||||
import type { CompatibilityEvent } from 'h3'
|
import type { CompatibilityEvent } from 'h3'
|
||||||
import { decodeAndVerifyJwtToken } from '~/somewhere/in/your/app/utils'
|
import { decodeAndVerifyJwtToken } from '~/somewhere/in/your/app/utils'
|
||||||
|
|
||||||
// The app's context - is generated for each incoming request
|
// 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
|
// Create your context based on the request object
|
||||||
// Will be available as `ctx` in all your resolvers
|
// Will be available as `ctx` in all your resolvers
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user