Merge pull request #34 from mahdiboomeri/chore

chore: bump nuxt to RC 12
This commit is contained in:
Robert Soriano
2022-10-21 08:10:53 -07:00
committed by GitHub
7 changed files with 820 additions and 888 deletions

View File

@@ -120,14 +120,14 @@ trpc-nuxt accepts the following options exposed under `~/server/trpc/index.ts`:
```ts ```ts
import * as trpc from '@trpc/server' import * as trpc from '@trpc/server'
import type { inferAsyncReturnType } 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' import type { OnErrorPayload } from 'trpc-nuxt/api'
export const router = trpc.router<inferAsyncReturnType<typeof createContext>>() export const router = trpc.router<inferAsyncReturnType<typeof createContext>>()
// Optional // Optional
// https://trpc.io/docs/context // https://trpc.io/docs/context
export const createContext = (event: CompatibilityEvent) => { export const createContext = (event: H3Event) => {
// ... // ...
return { return {
/** context data */ /** context data */

View File

@@ -32,27 +32,27 @@
"prepare": "nuxi prepare playground" "prepare": "nuxi prepare playground"
}, },
"dependencies": { "dependencies": {
"@nuxt/kit": "3.0.0-rc.11", "@nuxt/kit": "3.0.0-rc.12",
"@trpc/client": "^9.27.2", "@trpc/client": "^9.27.4",
"@trpc/server": "^9.27.2", "@trpc/server": "^9.27.4",
"dedent": "^0.7.0", "dedent": "^0.7.0",
"defu": "^6.0.0", "defu": "^6.1.0",
"h3": "^0.7.21", "h3": "^0.8.5",
"ohash": "^0.1.5", "ohash": "^0.1.5",
"pathe": "^0.3.0", "pathe": "^0.3.9",
"ufo": "^0.8.5" "ufo": "^0.8.6"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^0.23.1", "@antfu/eslint-config": "^0.23.1",
"@antfu/ni": "^0.16.2", "@antfu/ni": "^0.16.2",
"@nuxt/module-builder": "^0.1.7", "@nuxt/module-builder": "^0.2.0",
"@types/dedent": "^0.7.0", "@types/dedent": "^0.7.0",
"bumpp": "^7.2.0", "bumpp": "^7.2.0",
"eslint": "^8.14.0", "eslint": "^8.14.0",
"nuxt": "3.0.0-rc.11", "nuxt": "3.0.0-rc.12",
"pnpm": "^7.5.0", "pnpm": "^7.5.0",
"trpc-nuxt": "workspace:*", "trpc-nuxt": "workspace:*",
"zod": "^3.16.0" "zod": "^3.19.1"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "@antfu", "extends": "@antfu",

View File

@@ -1,4 +1,3 @@
import { defineNuxtConfig } from 'nuxt'
import Module from '../src/module' import Module from '../src/module'
// https://v3.nuxtjs.org/api/configuration/nuxt.config // https://v3.nuxtjs.org/api/configuration/nuxt.config

View File

@@ -1,7 +1,7 @@
import * as trpc from '@trpc/server' import * as trpc from '@trpc/server'
import type { inferAsyncReturnType } from '@trpc/server' import type { inferAsyncReturnType } from '@trpc/server'
import { z } from 'zod' import { z } from 'zod'
import type { CompatibilityEvent } from 'h3' import type { H3Event } from 'h3'
const baseURL = 'https://jsonplaceholder.typicode.com' 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 // 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

1669
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,11 +7,11 @@ The `createContext`-function is called for each incoming request so here you can
```ts ```ts
// ~/server/trpc/index.ts // ~/server/trpc/index.ts
import type { inferAsyncReturnType } from '@trpc/server' import type { inferAsyncReturnType } from '@trpc/server'
import type { CompatibilityEvent } from 'h3' import type { H3Event } 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({ req }: CompatibilityEvent) { export async function createContext({ req }: H3Event) {
// 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

View File

@@ -8,13 +8,13 @@ import type {
inferRouterError, inferRouterError,
} from '@trpc/server' } from '@trpc/server'
import { createURL } from 'ufo' import { createURL } from 'ufo'
import type { CompatibilityEvent } from 'h3' import type { H3Event } from 'h3'
import { defineEventHandler, isMethod, readBody } from 'h3' import { defineEventHandler, isMethod, readBody } from 'h3'
import type { TRPCResponse } from '@trpc/server/dist/declarations/src/rpc' import type { TRPCResponse } from '@trpc/server/dist/declarations/src/rpc'
type MaybePromise<T> = T | Promise<T> 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> { export interface ResponseMetaFnPayload<TRouter extends AnyRouter> {
data: TRPCResponse<unknown, inferRouterError<TRouter>>[] data: TRPCResponse<unknown, inferRouterError<TRouter>>[]
@@ -30,7 +30,7 @@ export interface OnErrorPayload<TRouter extends AnyRouter> {
error: TRPCError error: TRPCError
type: ProcedureType | 'unknown' type: ProcedureType | 'unknown'
path: string | undefined path: string | undefined
req: CompatibilityEvent['req'] req: H3Event['req']
input: unknown input: unknown
ctx: undefined | inferRouterContext<TRouter> ctx: undefined | inferRouterContext<TRouter>
} }