Files
Job-Info/ModeTemplate/types
aewing 05f8e2e3b6 Add ModeTemplate with Svelte 5 frontend and components
- Create reusable components: auth, api-client, shared-types
- ModeTemplate with Hono backend and SvelteKit frontend
- Auth store refactored to class-based Svelte 5 pattern
- SSR-safe hydrate() pattern for localStorage access
- Frontend builds successfully with Svelte 5 runes
2026-01-21 05:12:25 +00:00
..

Shared Types

Common types used by both frontend and backend. Keeps API contracts in sync.

Usage

import type { User, ApiResult, PaginatedResponse } from './components/shared-types';

// Backend endpoint
app.get('/api/users', async (c): Promise<ApiResult<PaginatedResponse<User>>> => {
  const users = await getUsers();
  return c.json({ success: true, data: users });
});

// Frontend call
const result = await api.get<ApiResult<PaginatedResponse<User>>>('/users');
if (result.ok && result.data?.success) {
  const users = result.data.data.items;
}

Types Included

User/Auth:

  • User - User record
  • AuthState - Frontend auth state

API Responses:

  • SuccessResponse<T> - { success: true, data: T }
  • ErrorResponse - { success: false, error: string }
  • ApiResult<T> - Either success or error
  • PaginatedResponse<T> - List with pagination metadata

Request Params:

  • PaginationParams - { page?, perPage? }
  • SortParams - { sort?, order? }
  • ListParams - Combined pagination + sort

Utility Types:

  • CreateInput<T> - Omits id and timestamps for creating
  • UpdateInput<T> - Partial without id/timestamps for updating

Copying to a Mode

  1. Copy components/shared-types/ to your mode root as types/
  2. Import from ./types in both frontend and backend

Dependencies

None - pure TypeScript types.