mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-26 01:40:31 +01:00
update types
This commit is contained in:
7
playground/.gitignore
vendored
Normal file
7
playground/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
*.log*
|
||||
.nuxt
|
||||
.nitro
|
||||
.cache
|
||||
.output
|
||||
.env
|
||||
42
playground/README.md
Normal file
42
playground/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Nuxt 3 Minimal Starter
|
||||
|
||||
Look at the [nuxt 3 documentation](https://v3.nuxtjs.org) to learn more.
|
||||
|
||||
## Setup
|
||||
|
||||
Make sure to install the dependencies:
|
||||
|
||||
```bash
|
||||
# yarn
|
||||
yarn install
|
||||
|
||||
# npm
|
||||
npm install
|
||||
|
||||
# pnpm
|
||||
pnpm install --shamefully-hoist
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
Start the development server on http://localhost:3000
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Production
|
||||
|
||||
Build the application for production:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
Locally preview production build:
|
||||
|
||||
```bash
|
||||
npm run preview
|
||||
```
|
||||
|
||||
Checkout the [deployment documentation](https://v3.nuxtjs.org/docs/deployment) for more information.
|
||||
14
playground/app.vue
Normal file
14
playground/app.vue
Normal file
@@ -0,0 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
const { data, error } = await useTrpcQuery('getUser', {
|
||||
name: 'john',
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
console.log(data.value)
|
||||
console.log('err', error.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>hello</div>
|
||||
</template>
|
||||
10
playground/nuxt.config.ts
Normal file
10
playground/nuxt.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
import Module from '..'
|
||||
|
||||
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
||||
export default defineNuxtConfig({
|
||||
modules: [Module],
|
||||
typescript: {
|
||||
strict: true,
|
||||
},
|
||||
})
|
||||
4
playground/package.json
Normal file
4
playground/package.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "playground",
|
||||
"private": true
|
||||
}
|
||||
16
playground/server/fn/index.ts
Normal file
16
playground/server/fn/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as trpc from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const router = trpc
|
||||
.router()
|
||||
.query('getUser', {
|
||||
input: z.object({ name: z.string().min(5) }),
|
||||
async resolve(req) {
|
||||
return { id: 1, name: req.input.name }
|
||||
},
|
||||
})
|
||||
.query('hello', {
|
||||
resolve: () => 'world',
|
||||
})
|
||||
|
||||
export type Router = typeof router
|
||||
Reference in New Issue
Block a user