Adding a feature
The checklist for a new page or resource in apps/web-ui.
Every change lands in one layer with one job (see API layer).
A new resource
- Model: response type in
lib/api/models/<name>.ts; add it to theModelsnamespace inmodels/index.ts. - DTO: zod request schema in
lib/api/dtos/<name>/schema.ts, reusing helpers fromlib/validation.ts. - Service: HTTP calls in
lib/api/services/<name>.tswith aClientFetchApiinstance; register it inservices/index.ts. - Queries:
queryOptions/mutationOptionsinlib/api/queries/<name>.ts. Start every key with the resource constant so oneinvalidateQueries({ queryKey: [KEY] })refreshes lists and details. Register inqueries/index.ts. - UI: components in
components/block/<feature>/. Read data withuseQuery(queries.<name>.list(...)), write withuseMutation(queries.<name>.create()), and surface errors withtoastAxiosError.
A new page
-
Add a route file under
src/routes, inside(dashboard)/when it needs a session:src/routes/(dashboard)/reports/index.tsx import { createFileRoute } from '@tanstack/react-router' import ReportsContent from '@/components/block/reports/content' export const Route = createFileRoute('/(dashboard)/reports/')({ head: () => ({ meta: [{ title: 'Reports | Cloudrive' }] }), component: ReportsContent, }) -
Run
bun run dev:weborbun run --filter @cloudrive/web-ui generate-routesto updatesrc/routeTree.gen.ts, and commit it. -
Add the entry to
data/sidebar-menu.ts. Setscope: 'workspace'when the page needs the active workspace, so the sidebar link carries?org=and?ws=.
Before you push
bun run --filter @cloudrive/web-ui build # vite buildKeep these rules (the first three fail the build when broken):
- No
next/*imports: this is a Vite app. Links come from@tanstack/react-router. - Type-only imports use
import type(verbatimModuleSyntaxis on). envis read only throughconfig/env.ts.- Never put a query string in a router
to; usesearchorhrefToLocation.