mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
Merge pull request #34 from mahdiboomeri/chore
chore: bump nuxt to RC 12
This commit is contained in:
@@ -120,14 +120,14 @@ trpc-nuxt accepts the following options exposed under `~/server/trpc/index.ts`:
|
||||
```ts
|
||||
import * as trpc from '@trpc/server'
|
||||
import type { inferAsyncReturnType } from '@trpc/server'
|
||||
import type { CompatibilityEvent } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
import type { OnErrorPayload } from 'trpc-nuxt/api'
|
||||
|
||||
export const router = trpc.router<inferAsyncReturnType<typeof createContext>>()
|
||||
|
||||
// Optional
|
||||
// https://trpc.io/docs/context
|
||||
export const createContext = (event: CompatibilityEvent) => {
|
||||
export const createContext = (event: H3Event) => {
|
||||
// ...
|
||||
return {
|
||||
/** context data */
|
||||
|
||||
20
package.json
20
package.json
@@ -32,27 +32,27 @@
|
||||
"prepare": "nuxi prepare playground"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/kit": "3.0.0-rc.11",
|
||||
"@trpc/client": "^9.27.2",
|
||||
"@trpc/server": "^9.27.2",
|
||||
"@nuxt/kit": "3.0.0-rc.12",
|
||||
"@trpc/client": "^9.27.4",
|
||||
"@trpc/server": "^9.27.4",
|
||||
"dedent": "^0.7.0",
|
||||
"defu": "^6.0.0",
|
||||
"h3": "^0.7.21",
|
||||
"defu": "^6.1.0",
|
||||
"h3": "^0.8.5",
|
||||
"ohash": "^0.1.5",
|
||||
"pathe": "^0.3.0",
|
||||
"ufo": "^0.8.5"
|
||||
"pathe": "^0.3.9",
|
||||
"ufo": "^0.8.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.23.1",
|
||||
"@antfu/ni": "^0.16.2",
|
||||
"@nuxt/module-builder": "^0.1.7",
|
||||
"@nuxt/module-builder": "^0.2.0",
|
||||
"@types/dedent": "^0.7.0",
|
||||
"bumpp": "^7.2.0",
|
||||
"eslint": "^8.14.0",
|
||||
"nuxt": "3.0.0-rc.11",
|
||||
"nuxt": "3.0.0-rc.12",
|
||||
"pnpm": "^7.5.0",
|
||||
"trpc-nuxt": "workspace:*",
|
||||
"zod": "^3.16.0"
|
||||
"zod": "^3.19.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@antfu",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
import Module from '../src/module'
|
||||
|
||||
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as trpc from '@trpc/server'
|
||||
import type { inferAsyncReturnType } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
import type { CompatibilityEvent } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
|
||||
const baseURL = 'https://jsonplaceholder.typicode.com'
|
||||
|
||||
@@ -37,7 +37,7 @@ export const router = trpc.router<Context>()
|
||||
},
|
||||
})
|
||||
|
||||
export async function createContext(event: CompatibilityEvent) {
|
||||
export async function createContext(event: H3Event) {
|
||||
// Create your context based on the request object
|
||||
// Will be available as `ctx` in all your resolvers
|
||||
|
||||
|
||||
1669
pnpm-lock.yaml
generated
1669
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -7,11 +7,11 @@ The `createContext`-function is called for each incoming request so here you can
|
||||
```ts
|
||||
// ~/server/trpc/index.ts
|
||||
import type { inferAsyncReturnType } from '@trpc/server'
|
||||
import type { CompatibilityEvent } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
import { decodeAndVerifyJwtToken } from '~/somewhere/in/your/app/utils'
|
||||
|
||||
// The app's context - is generated for each incoming request
|
||||
export async function createContext({ req }: CompatibilityEvent) {
|
||||
export async function createContext({ req }: H3Event) {
|
||||
// Create your context based on the request object
|
||||
// Will be available as `ctx` in all your resolvers
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import type {
|
||||
inferRouterError,
|
||||
} from '@trpc/server'
|
||||
import { createURL } from 'ufo'
|
||||
import type { CompatibilityEvent } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
import { defineEventHandler, isMethod, readBody } from 'h3'
|
||||
import type { TRPCResponse } from '@trpc/server/dist/declarations/src/rpc'
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>
|
||||
|
||||
export type CreateContextFn<TRouter extends AnyRouter> = (event: CompatibilityEvent) => MaybePromise<inferRouterContext<TRouter>>
|
||||
export type CreateContextFn<TRouter extends AnyRouter> = (event: H3Event) => MaybePromise<inferRouterContext<TRouter>>
|
||||
|
||||
export interface ResponseMetaFnPayload<TRouter extends AnyRouter> {
|
||||
data: TRPCResponse<unknown, inferRouterError<TRouter>>[]
|
||||
@@ -30,7 +30,7 @@ export interface OnErrorPayload<TRouter extends AnyRouter> {
|
||||
error: TRPCError
|
||||
type: ProcedureType | 'unknown'
|
||||
path: string | undefined
|
||||
req: CompatibilityEvent['req']
|
||||
req: H3Event['req']
|
||||
input: unknown
|
||||
ctx: undefined | inferRouterContext<TRouter>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user