Skip to content

Commit

Permalink
tRPC 11 and all the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarscher committed Feb 2, 2024
1 parent a5e8da3 commit 779f21d
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 102 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

# expo
**/.expo/*
**/expo-env.d.ts

**/
# next.js
**/.next/*
/out/
Expand Down
56 changes: 28 additions & 28 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
28 changes: 14 additions & 14 deletions apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
32 changes: 16 additions & 16 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
18 changes: 18 additions & 0 deletions packages/api/src/trpc.ts
Original file line number Diff line number Diff line change
@@ -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<FetchHandlerRequestOptions<AnyTRPCRouter>, 'req' | 'endpoint'> &
Partial<Pick<FetchHandlerRequestOptions<AnyTRPCRouter>, '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<Context>().create({
transformer: superJson,
errorFormatter({ shape }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
Expand Down
39 changes: 20 additions & 19 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion packages/app/utils/trpc/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions packages/app/utils/trpc/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ 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) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
transformer: superjson,
fetch(url, options) {
return fetch(url, {
...options,
Expand All @@ -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`,
}),
],
})
Expand Down
22 changes: 11 additions & 11 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 4 additions & 0 deletions packages/ui/src/tamagui.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const webFontFamily =
const headingFont = createFont({
family: isWeb ? webFontFamily : 'System',
size: {
1: 10,
2: 12,
3: 14,
4: 16,
Expand All @@ -69,6 +70,7 @@ const headingFont = createFont({
10: 48,
},
lineHeight: {
1: 12,
2: 14,
3: 16,
4: 18,
Expand Down Expand Up @@ -123,6 +125,7 @@ const bodyFont = createFont({
3: 12,
4: 15,
5: 24,
6: 27,
7: 30,
8: 36,
9: 40,
Expand All @@ -139,6 +142,7 @@ const bodyFont = createFont({
3: 24,
4: 27,
5: 36,
6: 40,
7: 45,
8: 54,
9: 60,
Expand Down

0 comments on commit 779f21d

Please sign in to comment.