From 779f21d05e23cfc4decf0786066a4ea94db6ad25 Mon Sep 17 00:00:00 2001 From: Rob Marscher Date: Fri, 2 Feb 2024 17:19:48 -0500 Subject: [PATCH] tRPC 11 and all the latest --- .gitignore | 3 +- apps/expo/package.json | 56 +++++++++++++-------------- apps/next/package.json | 28 +++++++------- package.json | 12 +++--- packages/api/package.json | 32 +++++++-------- packages/api/src/trpc.ts | 18 +++++++++ packages/api/src/worker.ts | 2 +- packages/app/package.json | 39 ++++++++++--------- packages/app/utils/trpc/index.tsx | 2 +- packages/app/utils/trpc/index.web.tsx | 7 ++-- packages/ui/package.json | 22 +++++------ packages/ui/src/tamagui.config.ts | 4 ++ 12 files changed, 123 insertions(+), 102 deletions(-) diff --git a/.gitignore b/.gitignore index c3cf7fc9d..38b0fe883 100755 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,7 @@ # expo **/.expo/* -**/expo-env.d.ts - +**/ # next.js **/.next/* /out/ diff --git a/apps/expo/package.json b/apps/expo/package.json index 083684a7e..1e8b86ff8 100755 --- a/apps/expo/package.json +++ b/apps/expo/package.json @@ -16,41 +16,41 @@ "clean": "git clean -xdf .expo node_modules ios android" }, "dependencies": { - "@babel/runtime": "^7.23.2", + "@babel/runtime": "^7.23.9", "@shopify/flash-list": "^1.6.3", "@t4/ui": "workspace:*", "app": "workspace:*", "babel-plugin-module-resolver": "^5.0.0", - "burnt": "^0.12.1", - "expo": "^49.0.16", - "expo-apple-authentication": "~6.1.2", - "expo-constants": "~14.4.2", - "expo-crypto": "~12.6.0", - "expo-dev-client": "~2.4.11", - "expo-font": "~11.6.0", - "expo-image": "~1.5.1", - "expo-linear-gradient": "~12.5.0", - "expo-linking": "5.0.2", - "expo-router": "^2.0.11", - "expo-splash-screen": "^0.22.0", - "expo-status-bar": "~1.7.1", - "expo-system-ui": "^2.6.0", - "expo-updates": "^0.18.17", - "expo-web-browser": "~12.5.0", + "burnt": "^0.12.2", + "expo": "^50.0.4", + "expo-apple-authentication": "~6.3.0", + "expo-constants": "~15.4.5", + "expo-crypto": "~12.8.0", + "expo-dev-client": "~3.3.7", + "expo-font": "~11.10.2", + "expo-image": "~1.10.5", + "expo-linear-gradient": "~12.7.1", + "expo-linking": "6.2.2", + "expo-router": "^3.4.6", + "expo-splash-screen": "^0.26.4", + "expo-status-bar": "~1.11.1", + "expo-system-ui": "2.9.3", + "expo-updates": "^0.24.9", + "expo-web-browser": "~12.8.2", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-native": "^0.72.6", - "react-native-gesture-handler": "~2.13.4", - "react-native-mmkv": "^2.10.2", - "react-native-safe-area-context": "4.7.4", - "react-native-screens": "^3.27.0", - "react-native-svg": "^13.14.0" + "react-native": "^0.73.3", + "react-native-gesture-handler": "~2.14.1", + "react-native-mmkv": "^2.11.0", + "react-native-safe-area-context": "4.9.0", + "react-native-screens": "^3.29.0", + "react-native-svg": "^14.1.0" }, "devDependencies": { - "@babel/core": "^7.23.2", - "@expo/metro-config": "^0.10.7", - "@tamagui/babel-plugin": "1.88.18", - "metro-minify-terser": "^0.80.0", - "typescript": "^5.2.2" + "@babel/core": "^7.23.9", + "@expo/metro-config": "^0.17.3", + "@tamagui/babel-plugin": "1.88.20", + "metro-minify-terser": "^0.80.5", + "typescript": "^5.3.3" } } diff --git a/apps/next/package.json b/apps/next/package.json index 1c035e788..66e913338 100644 --- a/apps/next/package.json +++ b/apps/next/package.json @@ -12,33 +12,33 @@ "clean": "git clean -xdf .next node_modules .tamagui" }, "dependencies": { - "@cloudflare/next-on-pages": "1.8.3", - "@ducanh2912/next-pwa": "^9.7.2", + "@cloudflare/next-on-pages": "1.8.6", + "@ducanh2912/next-pwa": "^10.2.4", "@fullhuman/postcss-purgecss": "^5.0.0", - "@supabase/auth-helpers-nextjs": "^0.7.4", + "@supabase/auth-helpers-nextjs": "^0.9.0", "@supabase/auth-helpers-react": "^0.4.2", "@t4/ui": "workspace:*", - "@tamagui/next-theme": "1.88.18", - "@tsndr/cloudflare-worker-jwt": "2.2.7", + "@tamagui/next-theme": "1.88.20", + "@tsndr/cloudflare-worker-jwt": "2.4.5", "app": "workspace:*", - "million": "2.6.4", - "next": "14.0.1", + "million": "3.0.2", + "next": "14.1.0", "next-seo": "^6.4.0", - "next-superjson-plugin": "^0.5.10", + "next-superjson-plugin": "^0.6.1", "pattycake": "^0.0.2", "postcss": "^8.4.33", "postcss-flexbugs-fixes": "^5.0.2", "postcss-preset-env": "^9.3.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-native": "^0.72.6", + "react-native": "^0.73.3", "react-native-web": "^0.19.10", - "webpack": "^5.88.2" + "webpack": "^5.90.1" }, "devDependencies": { - "@tamagui/next-plugin": "1.88.18", - "@types/react": "^18.2.37", - "vercel": "33.0.2", - "wrangler": "3.22.3" + "@tamagui/next-plugin": "1.88.20", + "@types/react": "^18.2.51", + "vercel": "33.4.1", + "wrangler": "3.26.0" } } diff --git a/package.json b/package.json index d75b02146..08bd8167c 100755 --- a/package.json +++ b/package.json @@ -36,15 +36,15 @@ }, "workspaces": ["apps/*", "packages/*"], "dependencies": { - "@babel/runtime": "^7.23.2", - "@biomejs/biome": "1.3.3", - "@manypkg/cli": "^0.21.0", + "@babel/runtime": "^7.23.9", + "@biomejs/biome": "1.5.3", + "@manypkg/cli": "^0.21.2", "@nderscore/tamagui-typescript-plugin": "^0.6.0", - "@supabase/supabase-js": "^2.38.4", + "@supabase/supabase-js": "^2.39.3", "check-dependency-version-consistency": "^4.1.0", "npm-run-all": "^4.1.5", "react-native-url-polyfill": "^2.0.0", - "typescript": "^5.2.2", - "workerd": "1.20231218.0" + "typescript": "^5.3.3", + "workerd": "1.20240129.0" } } diff --git a/packages/api/package.json b/packages/api/package.json index df822436f..ba39ad6b6 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -17,29 +17,29 @@ "clean": "rm -rf .turbo node_modules" }, "dependencies": { - "@cloudflare/next-on-pages": "1.8.3", + "@cloudflare/next-on-pages": "1.8.6", "@cloudflare/workers-wasi": "^0.0.5", "@hono/trpc-server": "^0.1.0", - "@libsql/client": "^0.3.5", + "@libsql/client": "^0.4.3", "@lucia-auth/adapter-drizzle": "1.0.0", - "@trpc/server": "^10.43.2", + "@trpc/server": "next", "arctic": "1.1.3", - "drizzle-orm": "^0.29.0", + "drizzle-orm": "^0.29.3", "drizzle-valibot": "beta", - "hono": "^3.9.2", + "hono": "^3.12.10", "lucia": "3.0.1", - "miniflare": "3.20231218.1", - "oslo": "1.0.3", - "superjson": "1.13.3", - "ts-pattern": "^5.0.5", - "valibot": "^0.20.1" + "miniflare": "3.20240129.0", + "oslo": "1.0.4", + "superjson": "2.2.1", + "ts-pattern": "^5.0.6", + "valibot": "^0.27.1" }, "devDependencies": { - "@cloudflare/next-on-pages": "1.8.3", - "@cloudflare/workers-types": "^4.20231218.0", - "bun-types": "^1.0.11", - "drizzle-kit": "^0.20.1", - "typescript": "^5.2.2", - "wrangler": "3.22.3" + "@cloudflare/next-on-pages": "1.8.6", + "@cloudflare/workers-types": "^4.20240129.0", + "bun-types": "^1.0.25", + "drizzle-kit": "^0.20.14", + "typescript": "^5.3.3", + "wrangler": "3.26.0" } } diff --git a/packages/api/src/trpc.ts b/packages/api/src/trpc.ts index 4b6e45c25..62241279a 100644 --- a/packages/api/src/trpc.ts +++ b/packages/api/src/trpc.ts @@ -1,8 +1,26 @@ +import type { AnyTRPCRouter } from '@trpc/server' +import type { FetchHandlerRequestOptions } from '@trpc/server/adapters/fetch' +import { fetchRequestHandler } from '@trpc/server/adapters/fetch' import { TRPCError, initTRPC } from '@trpc/server' +import type { MiddlewareHandler } from 'hono' import superJson from 'superjson' import { type Context } from './context' import { ObjectSchema, ObjectEntries, parse } from 'valibot' +type tRPCOptions = Omit, 'req' | 'endpoint'> & + Partial, 'endpoint'>> + +export const trpcServer = ({ endpoint = '/trpc', ...rest }: tRPCOptions): MiddlewareHandler => { + return async (c) => { + const res = fetchRequestHandler({ + ...rest, + endpoint, + req: c.req.raw, + }) + return res + } +} + const t = initTRPC.context().create({ transformer: superJson, errorFormatter({ shape }) { diff --git a/packages/api/src/worker.ts b/packages/api/src/worker.ts index 60995d16e..3540f0ba7 100644 --- a/packages/api/src/worker.ts +++ b/packages/api/src/worker.ts @@ -2,7 +2,7 @@ import { Hono, type Context, type Next } from 'hono' import { appRouter } from '@t4/api/src/router' import { cors } from 'hono/cors' import { createContext } from '@t4/api/src/context' -import { trpcServer } from '@hono/trpc-server' +import { trpcServer } from './trpc' import scheduled from './scheduled' export type Bindings = Env & { diff --git a/packages/app/package.json b/packages/app/package.json index ffc49b61c..64e8cad23 100755 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -11,26 +11,27 @@ "@shopify/flash-list": "^1.6.3", "@t4/api": "workspace:*", "@t4/ui": "workspace:*", - "@tamagui/animations-react-native": "1.88.18", - "@tamagui/colors": "1.88.18", - "@tamagui/font-inter": "1.88.18", - "@tamagui/lucide-icons": "1.88.18", - "@tamagui/shorthands": "1.88.18", - "@tamagui/themes": "1.88.18", - "@tanstack/react-query": "^4.36.1", - "@trpc/client": "^10.43.2", - "@trpc/next": "^10.43.2", - "@trpc/react-query": "^10.43.2", - "burnt": "^0.12.1", - "expo-constants": "~14.4.2", - "expo-linking": "5.0.2", - "expo-secure-store": "^12.5.0", - "react-native-mmkv": "^2.10.2", - "react-native-safe-area-context": "4.7.4", - "solito": "^4.1.3", - "ts-pattern": "^5.0.5" + "@tamagui/animations-react-native": "1.88.20", + "@tamagui/colors": "1.88.20", + "@tamagui/font-inter": "1.88.20", + "@tamagui/lucide-icons": "1.88.20", + "@tamagui/shorthands": "1.88.20", + "@tamagui/themes": "1.88.20", + "@tanstack/react-query": "latest", + "@tanstack/react-query-devtools": "latest", + "@trpc/client": "next", + "@trpc/next": "next", + "@trpc/react-query": "next", + "burnt": "^0.12.2", + "expo-constants": "~15.4.5", + "expo-linking": "6.2.2", + "expo-secure-store": "^12.8.1", + "react-native-mmkv": "^2.11.0", + "react-native-safe-area-context": "4.9.0", + "solito": "^4.2.0", + "ts-pattern": "^5.0.6" }, "devDependencies": { - "@types/react": "^18.2.37" + "@types/react": "^18.2.51" } } diff --git a/packages/app/utils/trpc/index.tsx b/packages/app/utils/trpc/index.tsx index cf8db0446..a95bb081e 100644 --- a/packages/app/utils/trpc/index.tsx +++ b/packages/app/utils/trpc/index.tsx @@ -27,9 +27,9 @@ export const TRPCProvider: React.FC<{ const [queryClient] = useState(() => new QueryClient()) const [trpcClient] = useState(() => trpc.createClient({ - transformer: superjson, links: [ httpBatchLink({ + transformer: superjson, async headers() { const token = getSessionToken() return { diff --git a/packages/app/utils/trpc/index.web.tsx b/packages/app/utils/trpc/index.web.tsx index be847b75b..6583c6ce7 100644 --- a/packages/app/utils/trpc/index.web.tsx +++ b/packages/app/utils/trpc/index.web.tsx @@ -36,7 +36,6 @@ export function TRPCProvider(props: { children: React.ReactNode }) { // https://tanstack.com/query/latest/docs/react/guides/network-mode // If you are developing locally, you probably want to enable "always" network mode // so that tRPC will make requests to localhost. - transformer: superjson, links: [ loggerLink({ enabled: (opts) => @@ -44,6 +43,7 @@ export function TRPCProvider(props: { children: React.ReactNode }) { (opts.direction === 'down' && opts.result instanceof Error), }), httpBatchLink({ + transformer: superjson, fetch(url, options) { return fetch(url, { ...options, @@ -52,9 +52,8 @@ export function TRPCProvider(props: { children: React.ReactNode }) { // always try to include cookies }) }, - url: `${ - typeof window !== 'undefined' ? '' : process.env.NEXT_PUBLIC_API_URL - }/worker/trpc`, + url: `${typeof window !== 'undefined' ? '' : process.env.NEXT_PUBLIC_API_URL + }/worker/trpc`, }), ], }) diff --git a/packages/ui/package.json b/packages/ui/package.json index fe18da719..a8d5edf5f 100755 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -15,18 +15,18 @@ "@shopify/flash-list": "^1.6.3", "@supabase/supabase-js": "^2.38.4", "@t4/api": "workspace:*", - "@tamagui/animations-react-native": "1.88.18", - "@tamagui/font-inter": "1.88.18", - "@tamagui/react-native-media-driver": "1.88.18", - "@tamagui/shorthands": "1.88.18", - "@tamagui/theme-builder": "1.88.18", - "@tamagui/themes": "1.88.18", - "@tamagui/toast": "1.88.18", - "@tanstack/react-virtual": "3.0.0-beta.68", - "jotai": "^2.5.1", - "tamagui": "1.88.18" + "@tamagui/animations-react-native": "1.88.20", + "@tamagui/font-inter": "1.88.20", + "@tamagui/react-native-media-driver": "1.88.20", + "@tamagui/shorthands": "1.88.20", + "@tamagui/theme-builder": "1.88.20", + "@tamagui/themes": "1.88.20", + "@tamagui/toast": "1.88.20", + "@tanstack/react-virtual": "3.0.4", + "jotai": "^2.6.4", + "tamagui": "1.88.20" }, "devDependencies": { - "@tamagui/build": "1.88.18" + "@tamagui/build": "1.88.20" } } diff --git a/packages/ui/src/tamagui.config.ts b/packages/ui/src/tamagui.config.ts index df2861ced..f04d295f8 100644 --- a/packages/ui/src/tamagui.config.ts +++ b/packages/ui/src/tamagui.config.ts @@ -58,6 +58,7 @@ const webFontFamily = const headingFont = createFont({ family: isWeb ? webFontFamily : 'System', size: { + 1: 10, 2: 12, 3: 14, 4: 16, @@ -69,6 +70,7 @@ const headingFont = createFont({ 10: 48, }, lineHeight: { + 1: 12, 2: 14, 3: 16, 4: 18, @@ -123,6 +125,7 @@ const bodyFont = createFont({ 3: 12, 4: 15, 5: 24, + 6: 27, 7: 30, 8: 36, 9: 40, @@ -139,6 +142,7 @@ const bodyFont = createFont({ 3: 24, 4: 27, 5: 36, + 6: 40, 7: 45, 8: 54, 9: 60,