From 97dfefe6cda9e13295153438419f8907d2ea015e Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Sat, 29 Oct 2022 22:33:59 -0700 Subject: [PATCH] add superjson to playground --- playground/package.json | 1 + playground/plugins/trpc-client.ts | 3 +++ playground/server/trpc/index.ts | 5 ++++- pnpm-lock.yaml | 21 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/playground/package.json b/playground/package.json index e433c56..9690dcb 100644 --- a/playground/package.json +++ b/playground/package.json @@ -9,6 +9,7 @@ "postinstall": "nuxt prepare" }, "dependencies": { + "superjson": "^1.11.0", "trpc-nuxt": "workspace:*", "zod": "^3.19.1" }, diff --git a/playground/plugins/trpc-client.ts b/playground/plugins/trpc-client.ts index cc2b862..eb9a7a4 100644 --- a/playground/plugins/trpc-client.ts +++ b/playground/plugins/trpc-client.ts @@ -1,9 +1,12 @@ import { httpBatchLink, loggerLink } from '@trpc/client' import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client' +import superjson from 'superjson' import type { AppRouter } from '~~/server/trpc/routers' export default defineNuxtPlugin(() => { + const client = createTRPCNuxtProxyClient({ + transformer: superjson, links: [ // adds pretty logs to your console in development and logs errors in production loggerLink({ diff --git a/playground/server/trpc/index.ts b/playground/server/trpc/index.ts index 195a134..e6876fe 100644 --- a/playground/server/trpc/index.ts +++ b/playground/server/trpc/index.ts @@ -1,7 +1,10 @@ import { initTRPC } from '@trpc/server' +import superjson from 'superjson' import type { Context } from './context' -const t = initTRPC.context().create() +const t = initTRPC.context().create({ + transformer: superjson +}) /** * Create a router diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d6a3664..bd93b40 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,9 +38,11 @@ importers: playground: specifiers: nuxt: 3.0.0-rc.12 + superjson: ^1.11.0 trpc-nuxt: workspace:* zod: ^3.19.1 dependencies: + superjson: 1.11.0 trpc-nuxt: link:.. zod: 3.19.1 devDependencies: @@ -1878,6 +1880,13 @@ packages: /cookie-es/0.5.0: resolution: {integrity: sha512-RyZrFi6PNpBFbIaQjXDlFIhFVqV42QeKSZX1yQIl6ihImq6vcHNGMtqQ/QzY3RMPuYSkvsRwtnt5M9NeYxKt0g==} + /copy-anything/3.0.2: + resolution: {integrity: sha512-CzATjGXzUQ0EvuvgOCI6A4BGOo2bcVx8B+eC2nF862iv9fopnPQwlrbACakNCHRIJbCSBj+J/9JeDf60k64MkA==} + engines: {node: '>=12.13'} + dependencies: + is-what: 4.1.7 + dev: false + /core-util-is/1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: true @@ -3741,6 +3750,11 @@ packages: call-bind: 1.0.2 dev: true + /is-what/4.1.7: + resolution: {integrity: sha512-DBVOQNiPKnGMxRMLIYSwERAS5MVY1B7xYiGnpgctsOFvVDz9f9PFXXxMcTOHuoqYp4NK9qFYQaIC1NRRxLMpBQ==} + engines: {node: '>=12.13'} + dev: false + /is-wsl/2.2.0: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} @@ -5772,6 +5786,13 @@ packages: ts-interface-checker: 0.1.13 dev: true + /superjson/1.11.0: + resolution: {integrity: sha512-6PfAg1FKhqkwWvPb2uXhH4MkMttdc17eJ91+Aoz4s1XUEDZFmLfFx/xVA3wgkPxAGy5dpozgGdK6V/n20Wj9yg==} + engines: {node: '>=10'} + dependencies: + copy-anything: 3.0.2 + dev: false + /supports-color/5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'}