๐จ Code Style โ
๐ TypeScript โ
- Strict mode is enabled in
tsconfig.json - All code is written in TypeScript (
.tsand.tsxfiles) - No
anytypes unless absolutely necessary
๐ Naming Conventions โ
| Thing | Convention | Example |
|---|---|---|
| ๐ Files | kebab-case | order.controller.ts |
| ๐ค Variables & functions | camelCase | createOrder |
| ๐ท๏ธ Classes & types | PascalCase | OrderStatus |
| ๐ Constants | UPPER_SNAKE_CASE | MAX_FILE_SIZE |
| ๐๏ธ Database tables | snake_case | menu_items (via Prisma @@map) |
| ๐ API routes | kebab-case | /api/automation-rules |
๐๏ธ Controller Pattern โ
All API controllers follow the same pattern:
typescript
import { Request, Response } from 'express';
import { prisma } from '../lib/prisma.js';
export async function listItems(req: Request, res: Response) {
try {
const items = await prisma.menuItem.findMany();
res.json({ success: true, data: items });
} catch (error) {
res.status(500).json({ success: false, error: 'Failed to fetch items' });
}
}Key patterns:
- โ Export named async functions (not classes)
- ๐ก๏ธ Use
try/catchfor error handling - ๐ฆ Return
{ success: true, data }or{ success: false, error } - ๐๏ธ Use Prisma client directly in controllers
๐ Route Organization โ
Routes are organized by domain in packages/server/src/routes/:
- ๐ One file per domain (e.g.,
order.routes.ts) - ๐ Routes registered in
app.ts - ๐ง Middleware applied per-route, not globally
๐ Shared Types โ
Types shared between server and frontend packages live in packages/shared/src/types/. Import them as:
typescript
import { OrderStatus } from '@kitchenasty/shared';โจ Formatting โ
- ๐ ๏ธ Use your editor's built-in formatter or Prettier
- ๐ 2-space indentation
- โ๏ธ Single quotes for strings
- โ Semicolons required
- โก๏ธ Trailing commas in multi-line structures