Skip to content

๐ŸŽจ Code Style โ€‹

๐Ÿ“˜ TypeScript โ€‹

  • Strict mode is enabled in tsconfig.json
  • All code is written in TypeScript (.ts and .tsx files)
  • No any types unless absolutely necessary

๐Ÿ“› Naming Conventions โ€‹

ThingConventionExample
๐Ÿ“„ Fileskebab-caseorder.controller.ts
๐Ÿ”ค Variables & functionscamelCasecreateOrder
๐Ÿท๏ธ Classes & typesPascalCaseOrderStatus
๐Ÿ”  ConstantsUPPER_SNAKE_CASEMAX_FILE_SIZE
๐Ÿ—„๏ธ Database tablessnake_casemenu_items (via Prisma @@map)
๐ŸŒ API routeskebab-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/catch for 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