mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
initial commit
This commit is contained in:
8
playground/app.vue
Normal file
8
playground/app.vue
Normal file
@@ -0,0 +1,8 @@
|
||||
<script setup>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
Nuxt module playground!
|
||||
</div>
|
||||
</template>
|
||||
11
playground/nuxt.config.ts
Normal file
11
playground/nuxt.config.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { defineNuxtConfig } from 'nuxt'
|
||||
import MyModule from '..'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
MyModule,
|
||||
],
|
||||
myModule: {
|
||||
addPlugin: true,
|
||||
},
|
||||
})
|
||||
4
playground/package.json
Normal file
4
playground/package.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "playground",
|
||||
"private": true
|
||||
}
|
||||
7
playground/server/api/trpc/[query].ts
Normal file
7
playground/server/api/trpc/[query].ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// generated by trpc-nuxt
|
||||
import { createTRPCHandler } from 'trpc-nuxt/handler'
|
||||
import * as functions from '../../fn'
|
||||
export default createTRPCHandler({
|
||||
router: functions.router
|
||||
})
|
||||
|
||||
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