mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
update docs
This commit is contained in:
@@ -17,19 +17,15 @@ import type { H3Event } from 'h3'
|
||||
import { inferAsyncReturnType } from '@trpc/server'
|
||||
import { decodeAndVerifyJwtToken } from './somewhere/in/your/app/utils'
|
||||
|
||||
export async function createContext({
|
||||
req,
|
||||
res,
|
||||
}: H3Event) {
|
||||
export async function createContext(event: H3Event) {
|
||||
// Create your context based on the request object
|
||||
// Will be available as `ctx` in all your resolvers
|
||||
|
||||
// This is just an example of something you might want to do in your ctx fn
|
||||
const authorization = getRequestHeader(event, authorization)
|
||||
async function getUserFromHeader() {
|
||||
if (req.headers.authorization) {
|
||||
const user = await decodeAndVerifyJwtToken(
|
||||
req.headers.authorization.split(' ')[1],
|
||||
)
|
||||
if (authorization) {
|
||||
const user = await decodeAndVerifyJwtToken(authorization.split(' ')[1])
|
||||
return user
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user