Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@arche-template/server",
"@arche-template/store",
"@arche-template/tooling-scripts",
"@arche-template/trpc",
"@arche-template/typescript-config",
"@arche-template/ui",
"@arche-template/web",
Expand Down
Empty file removed .npmrc
Empty file.
3 changes: 1 addition & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Run `bun run repo:doctor` before release or after large cleanup passes.
## Repo-specific invariants

- tRPC: `apps/server/src/modules/<feature>/*.trpc.ts` → `apps/server/src/modules/trpc/app.router.ts`.
- `packages/trpc` is the **client contract only** (re-exports `AppRouter` / `createCaller`).
- tRPC contract: `apps/server/src/modules/trpc` exports `AppRouter` and `createCaller` directly to web/worker.
- Production default: Vercel web + Render Docker API + Neon + Upstash — [docs/production-playbook.md](docs/production-playbook.md).
- Prefer correctness and robustness over short-term convenience.

Expand All @@ -29,7 +29,6 @@ CI: `bun run ci:min` (full `bun run ci` on `main`/`prod`/`develop`) — [docs/ci
| `apps/web` | Next.js App Router; tRPC client + `trpcCaller` for RSC |
| `apps/server` | Express, Better Auth, `src/modules/*` |
| `apps/worker` | Background jobs (Redis/BullMQ when enabled) |
| `packages/trpc` | Client contract only |
| `packages/store` | Prisma schema and client |
| `packages/auth` | Better Auth server + client |
| `packages/backend-common` | `serverEnv`, Redis, BullMQ, logging, `validate-env` |
Expand Down
12 changes: 6 additions & 6 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@
"dev": "bun run ./src/index.ts",
"link": "bun run build && bun link",
"unlink": "bun unlink",
"test": "bun test",
"test": "bun test tests",
"lint": "oxlint",
"lint:fix": "oxlint --fix",
"check-types": "tsc --noEmit",
"pack:dry-run": "bun run build && npm pack --dry-run",
"pack:dry-run": "bun run build && bun pm pack --dry-run",
"prepublishOnly": "bun run build"
},
"dependencies": {
"@arche-template/registry": "workspace:*",
"@clack/prompts": "^1.4.0",
"picocolors": "^1.1.1",
"zod": "catalog:"
"picocolors": "^1.1.1"
},
"devDependencies": {
"@arche-template/registry": "workspace:*",
"@arche-template/typescript-config": "workspace:*",
"@types/node": "catalog:",
"oxlint": "catalog:",
"typescript": "catalog:"
"typescript": "catalog:",
"zod": "catalog:"
},
"engines": {
"node": ">=20.0.0"
Expand Down
1 change: 0 additions & 1 deletion apps/cli/src/lib/generators/agent-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function keyDirs(config: ProjectConfig): string[] {
dirs.push('`apps/server` — API server')
dirs.push('`packages/auth` — Better Auth configuration')
dirs.push('`packages/store` — Database schema and client')
dirs.push('`packages/trpc` — tRPC routers and context')
dirs.push('`packages/common` — Shared TypeScript helpers')
}
if (includeWorker) dirs.push('`apps/worker` — Background job processing')
Expand Down
15 changes: 4 additions & 11 deletions apps/cli/src/lib/generators/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,6 @@ export const protectedProcedure = t.procedure
`
}

/** Keep @arche-template/trpc as a thin re-export for web clients */
function trpcIndexFetch(): string {
return `export type { AppRouter, RouterInputs, RouterOutputs } from '@arche-template/server/trpc'
`
}

/** Server-side tRPC barrel after removing Express-only route modules (Hono fetch adapter). */
function trpcIndexFetchServer(): string {
return `import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server'
Expand Down Expand Up @@ -663,10 +657,10 @@ export async function applyBackendTransform(
// 3. Patch server package.json
await patchPackageJson(join(destinationDir, serverDir, 'package.json'), honoPackageJsonPatch())

// 4. Rewrite tRPC package for fetch-based context (fullstack only)
const trpcSrcDir = join(destinationDir, 'packages', 'trpc', 'src')
// 4. Rewrite tRPC server module for fetch-based context (fullstack only)
const trpcModuleDir = join(destinationDir, serverDir, 'src/modules/trpc')
try {
await stat(trpcSrcDir)
await stat(trpcModuleDir)
await writeFile_(
join(destinationDir, serverDir, 'src/modules/trpc/trpc.ts'),
trpcContextFetch(),
Expand All @@ -675,9 +669,8 @@ export async function applyBackendTransform(
join(destinationDir, serverDir, 'src/modules/trpc/index.ts'),
trpcIndexFetchServer(),
)
await writeFile_(join(destinationDir, 'packages/trpc/src/index.ts'), trpcIndexFetch())
} catch {
// tRPC package not present — standalone or polyglot without tRPC
// tRPC module not present — standalone or polyglot without tRPC
}

await patchFullstackHomepageCopy(destinationDir, config.backend)
Expand Down
1 change: 0 additions & 1 deletion apps/cli/src/lib/generators/bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ This project was scaffolded with the **product** bundle (auth, database, API).
- \`apps/web\` — Next.js frontend
- \`apps/server\` — Express API + tRPC + Better Auth
- \`packages/store\` — Database (Prisma/Drizzle)
- \`packages/trpc\` — API contract (re-exports server router)
- \`packages/auth\` — Better Auth configuration

## Commands
Expand Down
7 changes: 2 additions & 5 deletions apps/cli/src/lib/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ async function pruneServiceApiFullstack(destinationDir: string): Promise<string[
'apps/web/trpc',
'packages/auth',
'packages/store',
'packages/trpc',
'packages/backend-common',
'packages/common',
]) {
Expand Down Expand Up @@ -604,11 +603,10 @@ async function pruneServiceApiFullstack(destinationDir: string): Promise<string[
})

await patchJsonFile(join(destinationDir, 'apps/web/package.json'), (pkg) => {
removeWorkspacePackages(pkg.dependencies, ['auth', 'store', 'trpc', 'common', 'server'])
removeWorkspacePackages(pkg.dependencies, ['auth', 'store', 'common', 'server'])
removeKeys(pkg.dependencies, [
'@arche-template/auth',
'@arche-template/store',
'@arche-template/trpc',
'@arche-template/common',
'@arche-template/server',
'@trpc/client',
Expand All @@ -624,11 +622,10 @@ async function pruneServiceApiFullstack(destinationDir: string): Promise<string[
await patchJsonFile(join(destinationDir, 'apps/web/tsconfig.json'), (tsconfig) => {
const compilerOptions = tsconfig.compilerOptions as Record<string, unknown> | undefined
const paths = compilerOptions?.paths as Record<string, unknown> | undefined
removeWorkspacePathAliases(paths, ['auth', 'store', 'trpc', 'common', 'server'])
removeWorkspacePathAliases(paths, ['auth', 'store', 'common', 'server'])
removeKeys(paths, [
'@arche-template/store/*',
'@arche-template/auth/*',
'@arche-template/trpc/*',
'@arche-template/common/*',
'@arche-template/server/*',
])
Expand Down
7 changes: 5 additions & 2 deletions apps/cli/src/lib/web-core.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { readFileSync } from 'node:fs'
import { existsSync, readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'

const WEB_CORE_DIR = join(dirname(fileURLToPath(import.meta.url)), '../templates/_web-core')
const __dir = dirname(fileURLToPath(import.meta.url))
const WEB_CORE_DIR = existsSync(join(__dir, '../templates/_web-core'))
? join(__dir, '../templates/_web-core')
: join(__dir, '../src/templates/_web-core')

export interface WebCoreVersions {
dependencies: Record<string, string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type RefObject,
} from 'react'

import type { RouterOutputs } from '@arche-template/trpc'
import type { RouterOutputs } from '@arche-template/server/trpc'
import { liveStreamUrl } from '@/lib/live-chat-sync'
import {
createLiveFeed,
Expand Down Expand Up @@ -76,7 +76,9 @@ export function LiveRoomProvider({ children }: { children: React.ReactNode }) {
}, [queryClient, trpc.chat.list, trpc.lattice.getState])

const handlersRef = useRef({ onEvent, onPollTick })
handlersRef.current = { onEvent, onPollTick }
useEffect(() => {
handlersRef.current = { onEvent, onPollTick }
}, [onEvent, onPollTick])

useEffect(() => {
const feed = createLiveFeed({
Expand Down
1 change: 0 additions & 1 deletion apps/cli/src/templates/fullstack/.archefiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"packages/backend-common",
"packages/common",
"packages/store",
"packages/trpc",
"toolings/typescript-config"
],
"exclude": [".vercel", "logs"]
Expand Down
1 change: 0 additions & 1 deletion apps/cli/src/templates/fullstack/apps/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@/*": ["./src/*"],
"@arche-template/store/*": ["../../packages/store/src/*"],
"@arche-template/auth/*": ["../../packages/auth/src/*"],
"@arche-template/trpc/*": ["../../packages/trpc/src/*"],
"@arche-template/backend-common/*": ["../../packages/backend-common/src/*"],
"@arche-template/common/*": ["../../packages/common/src/*"]
}
Expand Down
1 change: 0 additions & 1 deletion apps/cli/src/templates/fullstack/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@arche-template/common": "workspace:*",
"@arche-template/server": "workspace:*",
"@arche-template/store": "workspace:*",
"@arche-template/trpc": "workspace:*",
"@tanstack/react-query": "^5.101.1",
"@trpc/client": "^11.18.0",
"@trpc/tanstack-react-query": "^11.18.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/templates/fullstack/apps/web/trpc/client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import type { AppRouter } from '@arche-template/trpc'
import type { AppRouter } from '@arche-template/server/trpc'
import type { QueryClient } from '@tanstack/react-query'
import { QueryClientProvider } from '@tanstack/react-query'
import { createTRPCClient, httpBatchLink, loggerLink } from '@trpc/client'
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/templates/fullstack/apps/web/trpc/server.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'server-only'
import type { AppRouter } from '@arche-template/trpc'
import type { AppRouter } from '@arche-template/server/trpc'
import { dehydrate, HydrationBoundary } from '@tanstack/react-query'
import { createTRPCClient, httpLink } from '@trpc/client'
import { createTRPCOptionsProxy, TRPCQueryOptions } from '@trpc/tanstack-react-query'
Expand Down
5 changes: 2 additions & 3 deletions apps/cli/src/templates/fullstack/apps/worker/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"@/*": ["src/*"],
"@arche-template/store/*": ["../../packages/store/src/*"],
"@arche-template/auth/*": ["../../packages/auth/src/*"],
"@arche-template/trpc/*": ["../../packages/trpc/src/*"],
"@arche-template/backend-common/*": ["../../packages/trpc/backend-common/src/*"],
"@arche-template/common/*": ["../../packages/trpc/common/src/*"]
"@arche-template/backend-common/*": ["../../packages/backend-common/src/*"],
"@arche-template/common/*": ["../../packages/common/src/*"]
},
"outDir": "dist"
}
Expand Down
34 changes: 0 additions & 34 deletions apps/cli/src/templates/fullstack/packages/trpc/.gitignore

This file was deleted.

26 changes: 0 additions & 26 deletions apps/cli/src/templates/fullstack/packages/trpc/AGENTS.md

This file was deleted.

8 changes: 0 additions & 8 deletions apps/cli/src/templates/fullstack/packages/trpc/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions apps/cli/src/templates/fullstack/packages/trpc/package.json

This file was deleted.

15 changes: 0 additions & 15 deletions apps/cli/src/templates/fullstack/packages/trpc/src/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions apps/cli/src/templates/fullstack/packages/trpc/tsconfig.json

This file was deleted.

16 changes: 0 additions & 16 deletions apps/cli/tests/backend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('applyBackendTransform', () => {
await mkdir(join(tempDir, 'apps/server/src/modules/auth'), { recursive: true })
await mkdir(join(tempDir, 'apps/server/src/modules/health'), { recursive: true })
await mkdir(join(tempDir, 'apps/server/src/modules/root'), { recursive: true })
await mkdir(join(tempDir, 'packages/trpc/src'), { recursive: true })

// Mock Express app.ts
await writeFile(
Expand Down Expand Up @@ -96,12 +95,6 @@ describe('applyBackendTransform', () => {
join(tempDir, 'apps/server/src/modules/trpc/trpc.ts'),
'import { createExpressMiddleware } from "@trpc/server/adapters/express"\n',
)
// Mock tRPC index.ts
await writeFile(
join(tempDir, 'packages/trpc/src/index.ts'),
'export { expressMiddleWare } from "./middleware"\n',
)
// Mock Express-only artifacts removed by hono-bun transform
await writeFile(
join(tempDir, 'apps/server/src/vercel-handler.ts'),
'import express from "express"\n',
Expand Down Expand Up @@ -212,15 +205,6 @@ describe('applyBackendTransform', () => {
expect(trpcTs).not.toContain('CreateExpressContextOptions')
})

it('rewrites tRPC index.ts to client contract types only', async () => {
await applyBackendTransform(tempDir, makeConfig({ backend: 'hono-bun' }))
const indexTs = await readFile(join(tempDir, 'packages/trpc/src/index.ts'), 'utf8')
expect(indexTs).toContain('AppRouter')
expect(indexTs).toContain('RouterInputs')
expect(indexTs).not.toContain('expressMiddleWare')
expect(indexTs).not.toContain('createCaller')
})

it('app.ts mounts auth, trpc, health, and 404 routes', async () => {
await applyBackendTransform(tempDir, makeConfig({ backend: 'hono-bun' }))
const content = await readFile(join(tempDir, 'apps/server/src/app.ts'), 'utf8')
Expand Down
Loading
Loading