mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-26 09:50:31 +01:00
Compare commits
4 Commits
v0.4.0-bet
...
v0.4.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebb6637238 | ||
|
|
0c83ade918 | ||
|
|
97d9b3ddf8 | ||
|
|
eaa61f3700 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "trpc-nuxt",
|
"name": "trpc-nuxt",
|
||||||
"version": "0.4.0-beta.3",
|
"version": "0.4.0-beta.4",
|
||||||
"packageManager": "pnpm@7.5.0",
|
"packageManager": "pnpm@7.14.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"release": "bumpp --commit --push --tag && npm publish"
|
"release": "bumpp && npm publish"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@trpc/client": "^10.0.0-proxy-beta.21",
|
"@trpc/client": "^10.0.0-proxy-beta.21",
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"bumpp": "^8.2.1",
|
"bumpp": "^8.2.1",
|
||||||
"eslint": "^8.25.0",
|
"eslint": "^8.25.0",
|
||||||
"nuxt": "3.0.0-rc.12",
|
"nuxt": "3.0.0-rc.12",
|
||||||
"pnpm": "^7.5.0",
|
"pnpm": "^7.14.1",
|
||||||
"tsup": "6.0.1",
|
"tsup": "6.0.1",
|
||||||
"typescript": "^4.7.4"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
|
|||||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -13,7 +13,7 @@ importers:
|
|||||||
h3: ^0.8.5
|
h3: ^0.8.5
|
||||||
nuxt: 3.0.0-rc.12
|
nuxt: 3.0.0-rc.12
|
||||||
ohash: ^0.1.5
|
ohash: ^0.1.5
|
||||||
pnpm: ^7.5.0
|
pnpm: ^7.14.1
|
||||||
tsup: 6.0.1
|
tsup: 6.0.1
|
||||||
typescript: ^4.7.4
|
typescript: ^4.7.4
|
||||||
ufo: ^0.8.6
|
ufo: ^0.8.6
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import type {
|
|||||||
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared'
|
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared'
|
||||||
import { hash } from 'ohash'
|
import { hash } from 'ohash'
|
||||||
import type { DecoratedProcedureRecord } from './types'
|
import type { DecoratedProcedureRecord } from './types'
|
||||||
|
// @ts-ignore: nuxt internal
|
||||||
|
import { useAsyncData, useState } from '#app'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the key used for `useAsyncData` call
|
* Calculates the key used for `useAsyncData` call
|
||||||
@@ -27,7 +29,7 @@ export function createNuxtProxyDecoration<TRouter extends AnyRouter>(name: strin
|
|||||||
const pathCopy = [name, ...opts.path]
|
const pathCopy = [name, ...opts.path]
|
||||||
|
|
||||||
// The last arg is for instance `.mutate` or `.query()`
|
// The last arg is for instance `.mutate` or `.query()`
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
const lastArg = pathCopy.pop()!
|
const lastArg = pathCopy.pop()!
|
||||||
|
|
||||||
const path = pathCopy.join('.')
|
const path = pathCopy.join('.')
|
||||||
@@ -44,9 +46,7 @@ export function createNuxtProxyDecoration<TRouter extends AnyRouter>(name: strin
|
|||||||
* Custom useAsyncData to add server error to client
|
* Custom useAsyncData to add server error to client
|
||||||
*/
|
*/
|
||||||
async function useAsyncDataWithError(queryKey: string, cb: any, asyncDataOptions: any) {
|
async function useAsyncDataWithError(queryKey: string, cb: any, asyncDataOptions: any) {
|
||||||
// @ts-ignore: nuxt internal
|
|
||||||
const serverError = useState(`error-${queryKey}`, () => null)
|
const serverError = useState(`error-${queryKey}`, () => null)
|
||||||
// @ts-ignore: nuxt internal
|
|
||||||
const { error, data, ...rest } = await useAsyncData(queryKey, cb, asyncDataOptions)
|
const { error, data, ...rest } = await useAsyncData(queryKey, cb, asyncDataOptions)
|
||||||
|
|
||||||
if (error.value && !serverError.value)
|
if (error.value && !serverError.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user