From c15940be679a491c909355c9542c311f58b1755e Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Wed, 21 Dec 2022 11:16:56 +0100 Subject: [PATCH 1/5] feat: generate context with correct type --- src/steps/2.addModules/moduleConfigs.ts | 14 +++++++++++++- src/steps/6.addReadme.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/steps/2.addModules/moduleConfigs.ts b/src/steps/2.addModules/moduleConfigs.ts index d449110..cb09142 100644 --- a/src/steps/2.addModules/moduleConfigs.ts +++ b/src/steps/2.addModules/moduleConfigs.ts @@ -141,12 +141,24 @@ export type AppRouter = typeof appRouter ` const nuxtTrpcContext = `import { inferAsyncReturnType } from '@trpc/server' +import type { H3Event } from 'h3' /** * Creates context for an incoming request * @link https://trpc.io/docs/context */ -export const createContext = () => {} +export async function createContext(event: H3Event) { + /** + * Add any trpc-request context here. E.g., you could add \`prisma\` like this if you've set it up: + * \`\`\` + * const prisma = usePrisma(event) + * return { prisma } + * \`\`\` + * + * You can import \`usePrisma\` like this: \`import { usePrisma } from '@sidebase/nuxt-prisma'\` + */ + return {} +} export type Context = inferAsyncReturnType; ` diff --git a/src/steps/6.addReadme.ts b/src/steps/6.addReadme.ts index 44fc8f6..61fdd9f 100644 --- a/src/steps/6.addReadme.ts +++ b/src/steps/6.addReadme.ts @@ -50,7 +50,7 @@ This is a straight-forward setup with minimal templating and scaffolding. The op Some tasks you should probably do in the beginning are: - [ ] replace this generic README with a more specific one - [ ] install the Vue Volar extension -- [ ] enable [Volar takeover mode](https://nuxt.com/docs/getting-started/installation#prerequisites) +- [ ] enable [Volar takeover mode](https://nuxt.com/docs/getting-started/installation#prerequisites) to ensure a smooth editor setup ${tasksPostInstall.join("\n")} ### Setup From 7b8396c6584c7c0520c8bce5bd6cd97ff24094b3 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Wed, 21 Dec 2022 11:27:41 +0100 Subject: [PATCH 2/5] feat: bump prisma to 4.8.0 --- src/steps/2.addModules/moduleConfigs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/steps/2.addModules/moduleConfigs.ts b/src/steps/2.addModules/moduleConfigs.ts index cb09142..98a75c1 100644 --- a/src/steps/2.addModules/moduleConfigs.ts +++ b/src/steps/2.addModules/moduleConfigs.ts @@ -235,12 +235,12 @@ export const moduleConfigs: Record = { dependencies: [ { name: "prisma", - version: "^4.7.1", + version: "^4.8.0", isDev: true }, { name: "@prisma/client", - version: "^4.7.1", + version: "^4.8.0", isDev: false }, { From ca78c58b7d291ed80d496330b68fe6eff144c45e Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Wed, 21 Dec 2022 11:41:13 +0100 Subject: [PATCH 3/5] feat: add superjson --- src/steps/2.addModules/moduleConfigs.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/steps/2.addModules/moduleConfigs.ts b/src/steps/2.addModules/moduleConfigs.ts index 98a75c1..726221b 100644 --- a/src/steps/2.addModules/moduleConfigs.ts +++ b/src/steps/2.addModules/moduleConfigs.ts @@ -108,8 +108,11 @@ const nuxtTrpcRootConfig = `/** */ import { initTRPC } from '@trpc/server' import { Context } from '~/server/trpc/context' +import superjson from 'superjson'; -const t = initTRPC.context().create() +const t = initTRPC.context().create({ + transformer: superjson, +}) /** * Unprotected procedure @@ -132,6 +135,7 @@ export const appRouter = router({ .query(({ input }) => { return { greeting: \`hello \${input?.text ?? "world"}\`, + time: new Date() } }), }) @@ -176,6 +180,7 @@ export default createNuxtApiHandler({ const nuxtTrpcPlugin = `import { createTRPCNuxtClient, httpBatchLink } from "trpc-nuxt/client" import type { AppRouter } from "~/server/trpc/routers" +import superjson from 'superjson'; export default defineNuxtPlugin(() => { /** @@ -183,6 +188,7 @@ export default defineNuxtPlugin(() => { * built on top of \`useAsyncData\`. */ const client = createTRPCNuxtClient({ + transformer: superjson, links: [ httpBatchLink({ url: "/api/trpc", @@ -206,7 +212,8 @@ const hello = await $client.hello.useQuery({ text: 'client' }) ` @@ -309,6 +316,10 @@ export const moduleConfigs: Record = { name: "zod", version: "^3.20.2", isDev: false + }, { + name: "superjson", + version: "^1.12.1", + isDev: false }], nuxtConfig: { build: { From c5602a40fc8efb368712b050f7ebf4d27e25c8e5 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Wed, 21 Dec 2022 11:41:26 +0100 Subject: [PATCH 4/5] feat: bump nuxt-orisma to 0.1.2 --- src/steps/2.addModules/moduleConfigs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/steps/2.addModules/moduleConfigs.ts b/src/steps/2.addModules/moduleConfigs.ts index 726221b..768bc9b 100644 --- a/src/steps/2.addModules/moduleConfigs.ts +++ b/src/steps/2.addModules/moduleConfigs.ts @@ -252,7 +252,7 @@ export const moduleConfigs: Record = { }, { name: "@sidebase/nuxt-prisma", - version: "^0.1.0", + version: "^0.1.2", isDev: false } ], From 8b13c1b252fbe527253e2158a552d3c7e123e7b4 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Wed, 21 Dec 2022 11:42:04 +0100 Subject: [PATCH 5/5] release: 0.2.6 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 97220d3..1f56439 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "create-sidebase", - "version": "0.2.5", + "version": "0.2.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "create-sidebase", - "version": "0.2.5", + "version": "0.2.6", "license": "MIT", "dependencies": { "@nuxt/schema": "^3.0.0", diff --git a/package.json b/package.json index cfedb4a..3e05249 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-sidebase", - "version": "0.2.5", + "version": "0.2.6", "description": "The productive way to build fullstack Nuxt 3 applications, like create-t3-app but for Nuxt.", "scripts": { "dev": "vite-node src/",