Shared

This directory contains code shared between frontend (browser) and backend (Deno).

Files

  • types.ts - TypeScript interfaces and types

    • Controller response format
    • Notion data structures
    • API request/response types
  • utils.ts - Utility functions

    • Must work in both browser AND Deno
    • NEVER use Deno APIs (won't work in browser)
    • ✅ Only use standard JavaScript/TypeScript

Guidelines

Adding Types

  • Define interfaces for data shared between layers
  • Use clear, descriptive names (PascalCase)
  • Document complex types with comments

Adding Utils

  • Test that functions work in both environments
  • Avoid platform-specific APIs (Deno, Node, browser-only)
  • Use pure functions when possible

Example

// ✅ Good - works everywhere export function formatDate(date: string): string { return new Date(date).toLocaleDateString(); } // ❌ Bad - Deno-specific export function readConfig() { return Deno.env.get('CONFIG'); // Won't work in browser! }