mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-21 15:31:44 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07693009f8 | ||
|
|
dceade155c | ||
|
|
4012249f09 | ||
|
|
38eda2c4d6 | ||
|
|
9468af75f4 | ||
|
|
ea24a67a6d | ||
|
|
5e8d04741c | ||
|
|
1032e65a0d | ||
|
|
f261d3feeb | ||
|
|
b1ca09e986 | ||
|
|
b804429fc0 | ||
|
|
7df64296ff |
@@ -29,10 +29,10 @@ export default defineNuxtConfig({
|
|||||||
modules: ['trpc-nuxt'],
|
modules: ['trpc-nuxt'],
|
||||||
trpc: {
|
trpc: {
|
||||||
baseURL: 'http://localhost:3000', // defaults to http://localhost:3000
|
baseURL: 'http://localhost:3000', // defaults to http://localhost:3000
|
||||||
endpoint: '/trpc', // defaults to /api/trpc
|
endpoint: '/trpc', // defaults to /trpc
|
||||||
},
|
},
|
||||||
typescript: {
|
typescript: {
|
||||||
strict: true // set this to true to make input/output types work
|
strict: true // required to make input/output types work
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
17
package.json
17
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "trpc-nuxt",
|
"name": "trpc-nuxt",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"packageManager": "pnpm@7.1.1",
|
"packageManager": "pnpm@7.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./dist/module.cjs",
|
"main": "./dist/module.cjs",
|
||||||
@@ -32,14 +32,14 @@
|
|||||||
"prepare": "nuxi prepare playground"
|
"prepare": "nuxi prepare playground"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/kit": "^3.0.0-rc.3",
|
"@nuxt/kit": "^3.0.0-rc.4",
|
||||||
"@trpc/client": "^9.23.3",
|
"@trpc/client": "^9.25.2",
|
||||||
"@trpc/server": "^9.23.2",
|
"@trpc/server": "^9.25.2",
|
||||||
"@vueuse/core": "^8.5.0",
|
"@vueuse/core": "^8.6.0",
|
||||||
"@vueuse/nuxt": "^8.5.0",
|
"@vueuse/nuxt": "^8.6.0",
|
||||||
"dedent": "^0.7.0",
|
"dedent": "^0.7.0",
|
||||||
"defu": "^6.0.0",
|
"defu": "^6.0.0",
|
||||||
"h3": "^0.7.8",
|
"h3": "^0.7.9",
|
||||||
"pathe": "^0.3.0",
|
"pathe": "^0.3.0",
|
||||||
"ufo": "^0.8.4"
|
"ufo": "^0.8.4"
|
||||||
},
|
},
|
||||||
@@ -49,10 +49,9 @@
|
|||||||
"@nuxt/module-builder": "latest",
|
"@nuxt/module-builder": "latest",
|
||||||
"bumpp": "^7.1.1",
|
"bumpp": "^7.1.1",
|
||||||
"eslint": "^8.14.0",
|
"eslint": "^8.14.0",
|
||||||
"nuxt": "^3.0.0-rc.3",
|
"nuxt": "3.0.0-rc.4",
|
||||||
"ohash": "^0.1.0",
|
"ohash": "^0.1.0",
|
||||||
"pnpm": "^7.1.1",
|
"pnpm": "^7.1.1",
|
||||||
"superjson": "^1.9.1",
|
|
||||||
"trpc-nuxt": "workspace:*",
|
"trpc-nuxt": "workspace:*",
|
||||||
"zod": "^3.16.0"
|
"zod": "^3.16.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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 { CompatibilityEvent } from 'h3'
|
||||||
import { useCookies } from 'h3'
|
|
||||||
|
|
||||||
const baseURL = 'https://jsonplaceholder.typicode.com'
|
const baseURL = 'https://jsonplaceholder.typicode.com'
|
||||||
|
|
||||||
@@ -30,6 +29,7 @@ export const router = trpc.router<Context>()
|
|||||||
.mutation('addTodo', {
|
.mutation('addTodo', {
|
||||||
input: TodoShape,
|
input: TodoShape,
|
||||||
async resolve(req) {
|
async resolve(req) {
|
||||||
|
console.log(req.input)
|
||||||
return await $fetch<Todo>(`${baseURL}/todos`, {
|
return await $fetch<Todo>(`${baseURL}/todos`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: req.input,
|
body: req.input,
|
||||||
|
|||||||
2070
pnpm-lock.yaml
generated
2070
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -40,6 +40,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
{ name: 'useClient', from: join(runtimeDir, 'client') },
|
{ name: 'useClient', from: join(runtimeDir, 'client') },
|
||||||
{ name: 'useAsyncQuery', from: join(runtimeDir, 'client') },
|
{ name: 'useAsyncQuery', from: join(runtimeDir, 'client') },
|
||||||
{ name: 'useClientHeaders', from: join(runtimeDir, 'client') },
|
{ name: 'useClientHeaders', from: join(runtimeDir, 'client') },
|
||||||
|
{ name: 'getQueryKey', from: join(runtimeDir, 'client') },
|
||||||
])
|
])
|
||||||
|
|
||||||
addServerHandler({
|
addServerHandler({
|
||||||
|
|||||||
Reference in New Issue
Block a user