Compare commits

...

18 Commits

Author SHA1 Message Date
wobsoriano
7a69573fb9 chore: release v0.7.0 2023-02-20 09:18:07 -08:00
wobsoriano
8e26e781d4 fix type errors 2023-02-20 09:18:03 -08:00
wobsoriano
8efb63e70c bump tsup to 6.6.3 2023-02-20 09:09:10 -08:00
wobsoriano
4f6c07b0a1 feat(deps): require trpc >10.12.0 2023-02-20 09:08:44 -08:00
wobsoriano
aa3fe5527d feat(deps): bump ufo to 1.1.0 2023-02-20 09:07:44 -08:00
wobsoriano
6f17913eab feat(deps): bump ofetch to 1.0.1 2023-02-20 09:07:18 -08:00
wobsoriano
d6c60cb2b3 feat(deps): bump h3 to 1.5.0 2023-02-20 09:06:56 -08:00
wobsoriano
76fbd59525 chore: release v0.6.0 2023-02-04 21:01:26 -08:00
wobsoriano
57faf8749a feat(deps): bump h3 to 1.1.0 2023-02-04 21:00:25 -08:00
wobsoriano
9456342d58 remove unused deps 2023-02-04 20:59:51 -08:00
wobsoriano
f89c8e44ef feat(deps): bump @trpc/client and @trpc/server to 10.10.0 2023-02-04 20:59:39 -08:00
wobsoriano
7f156806d8 add Acknowledgements section 2023-02-01 08:49:10 -08:00
wobsoriano
bd33589d2f add funding.yml 2023-01-31 20:03:14 -08:00
Robert Soriano
16b6ed315a Merge pull request #68 from CodyBontecou/patch-1
Update 1.simple.md
2023-01-25 22:42:38 -05:00
Cody Bontecou
6e74e44233 Update 1.simple.md
Updated to use destructuring syntax.
2023-01-25 15:18:16 -10:00
Cody Bontecou
6485aa42a7 Update 1.simple.md
Walking through the setup with Nuxt v3.1.0 requires accessing `.value` within the template.
2023-01-25 13:00:50 -10:00
Robert Soriano
051d5bb325 Update 1.composables.md 2023-01-09 10:33:17 -08:00
Robert Soriano
b7d4dc7642 Update 1.composables.md 2023-01-09 10:33:07 -08:00
9 changed files with 421 additions and 178 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
github: wobsoriano

View File

@@ -27,6 +27,10 @@ For version 3 of this module (tRPC v9, auto-imports, auto handlers), [go here](h
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
## Acknowledgements
Huge thanks to [Alex / KATT](https://github.com/KATT), the author of [tRPC](https://trpc.io/), for being the first sponsor of this project! 🎉
## License
MIT

View File

@@ -107,12 +107,12 @@ export default defineNuxtPlugin(() => {
<script setup lang="ts">
const { $client } = useNuxtApp()
const hello = await $client.hello.useQuery({ text: 'client' })
const { data: hello } = await $client.hello.useQuery({ text: 'client' })
</script>
<template>
<div>
<p>{{ hello.data?.greeting }}</p>
<p>{{ hello?.greeting }}</p>
</div>
</template>
```

View File

@@ -7,7 +7,7 @@ title: Composables
It is often useful to wrap functionality of your `@trpc/client` api within other functions. For this purpose, it's necessary to be able to infer input types and output types generated by your `@trpc/server` router.
::alert{type="info"}
[createTRPCNuxtClient](/get-started/client/create) adds a `useQuery` method built on top of [useAsyncData](https://nuxt.com/docs/api/composables/use-async-data/).
[createTRPCNuxtClient](/get-started/client/create) already adds a `useQuery` method built on top of [useAsyncData](https://nuxt.com/docs/api/composables/use-async-data/). You might not need this.
::
## Inference Helpers

View File

@@ -3,7 +3,7 @@
"description": "End-to-end typesafe APIs in Nuxt applications.",
"type": "module",
"packageManager": "pnpm@7.18.2",
"version": "0.5.0",
"version": "0.7.0",
"license": "MIT",
"sideEffects": false,
"exports": {
@@ -25,7 +25,7 @@
"client.d.ts"
],
"scripts": {
"dev": "concurrently \"pnpm build --watch\" \"pnpm --filter playground dev\"",
"dev": "tsup --watch --onSuccess \"pnpm --filter playground dev\"",
"dev:prepare": "pnpm build && nuxt prepare playground",
"prepublishOnly": "pnpm build",
"build": "tsup",
@@ -35,25 +35,24 @@
"update-deps": "taze -w && pnpm i"
},
"peerDependencies": {
"@trpc/client": "^10.8.0",
"@trpc/server": "^10.8.0"
"@trpc/client": "^10.12.0",
"@trpc/server": "^10.12.0"
},
"dependencies": {
"h3": "^1.0.2",
"ofetch": "^1.0.0",
"h3": "^1.5.0",
"ofetch": "^1.0.1",
"ohash": "^1.0.0",
"ufo": "^1.0.1"
"ufo": "^1.1.0"
},
"devDependencies": {
"@nuxt/eslint-config": "^0.1.1",
"@trpc/client": "^10.8.1",
"@trpc/server": "^10.8.1",
"@trpc/client": "^10.12.0",
"@trpc/server": "^10.12.0",
"bumpp": "^8.2.1",
"concurrently": "^7.6.0",
"eslint": "^8.30.0",
"eslint": "^8.33.0",
"taze": "^0.8.5",
"tsup": "6.4.0",
"typescript": "^4.9.4"
"tsup": "6.6.3",
"typescript": "^4.9.5"
},
"eslintConfig": {
"extends": [

548
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -69,7 +69,7 @@ export function createTRPCNuxtClient<TRouter extends AnyRouter> (opts: CreateTRP
const client = createTRPCProxyClient<TRouter>(opts)
const decoratedClient = createFlatProxy((key) => {
return createNuxtProxyDecoration(key, client)
return createNuxtProxyDecoration(key, client as any)
}) as DecoratedProcedureRecord<TRouter['_def']['record'], TRouter>
return decoratedClient

View File

@@ -4,6 +4,7 @@ import { FetchError } from 'ofetch'
// @ts-expect-error: Nuxt auto-imports
import { useRequestHeaders } from '#imports'
import { type HTTPLinkOptions as _HTTPLinkOptions } from '@trpc/client/dist/links/internals/httpUtils'
import { type FetchEsque } from '@trpc/client/dist/internals/types'
function customFetch(input: RequestInfo | URL, init?: RequestInit) {
return globalThis.$fetch.raw(input.toString(), init)
@@ -43,7 +44,7 @@ export function httpLink<TRouter extends AnyRouter>(opts?: HTTPLinkOptions) {
headers () {
return headers
},
fetch: customFetch,
fetch: customFetch as FetchEsque,
...opts,
})
}
@@ -72,7 +73,7 @@ export function httpBatchLink<TRouter extends AnyRouter>(opts?: HttpBatchLinkOpt
headers () {
return headers
},
fetch: customFetch,
fetch: customFetch as FetchEsque,
...opts,
})
}

View File

@@ -50,9 +50,13 @@ export interface ResolveHTTPRequestOptions<TRouter extends AnyRouter> {
}
function getPath (event: H3Event): string | null {
if (typeof event.context.params.trpc === 'string') { return event.context.params.trpc }
const { params } = event.context
if (Array.isArray(event.context.params.trpc)) { return event.context.params.trpc.join('/') }
if (typeof params?.trpc === 'string') { return params.trpc }
if (params?.trpc && Array.isArray(params.trpc)) {
return (params.trpc as string[]).join('/')
}
return null
}