initial commit

This commit is contained in:
Robert Soriano
2022-05-16 01:55:10 -07:00
commit b0eab95b47
15 changed files with 6864 additions and 0 deletions

27
src/module.ts Normal file
View File

@@ -0,0 +1,27 @@
import { dirname, resolve } from 'path'
import { defineNuxtModule } from '@nuxt/kit'
import fs from 'fs-extra'
export interface ModuleOptions {}
export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'trpc-nuxt',
configKey: 'trpc',
},
defaults: {},
async setup(_options, nuxt) {
const root = nuxt.options.rootDir
const apiPath = resolve(root, 'server/api/trpc/[query].ts')
await fs.ensureDir(dirname(apiPath))
await fs.writeFile(apiPath, `
// generated by trpc-nuxt
import { createTRPCHandler } from 'trpc-nuxt/handler'
import * as functions from '../../fn'
export default createTRPCHandler({
router: functions.router
})
`.trimStart())
},
})