- Single centralized HTTP client at
src/lib/api/client.ts(Axios-based) - Automatic JWT token injection and refresh
- All API modules use this client for consistency
- Domain-organized API modules:
auth.ts,users.ts,residents.ts,apartments.ts, etc. - OpenAPI spec available in
docs/openapi.jsonfor backend contract - TypeScript types auto-generated from OpenAPI spec using
openapi-typescript
See: 3_openapi-typescript.md for details on type generation workflow
RULE: ONLY import types from @/lib/types. NEVER import from @/lib/types/api
@/lib/types is the single source of truth for all type imports across the entire codebase.
// API modules - use pre-exported query parameter types
import type {
UserDto,
UserCreateRequest,
CursorResponseUserDto,
FindUsersParams, // ✅ Pre-defined query params
} from '@/lib/types';// Store modules
import type {
ContentDto,
CursorResponseContentDto,
FindContentsParams,
} from '@/lib/types';// Components
import type { PlaylistDto, UserSummary } from '@/lib/types';// NEVER import directly from api.ts
import type { components } from '@/lib/types/api'; // ❌ WRONG
import type { operations } from '@/lib/types/api'; // ❌ WRONG
import type { paths } from '@/lib/types/api'; // ❌ WRONG
// NEVER use operations/components from @/lib/types
import type { operations } from '@/lib/types'; // ❌ WRONG
type Params = operations['findUsers']['parameters']['query']; // ❌ WRONG- Single Source of Truth: All type imports go through one entry point (
@/lib/types) - Encapsulation:
@/lib/types/apiis an internal implementation detail - Store Compatibility: Stores, API modules, and components all use the same import path
- Pre-defined Types: All commonly used types (including query params) are pre-exported
- Maintainability: Type changes only need to be managed in
@/lib/types/index.ts
All types are auto-generated from OpenAPI spec (docs/openapi.json) and exported via @/lib/types/index.ts:
- Schema types (DTOs):
LoginRequestDto,NoticeDetailResponseDto,ApartmentResponseDto, etc. - Request types:
CreateNoticeDto,UpdateResidentDto,SignupUserRequestDto, etc. - Response types:
LoginResponseDto,NoticesListWrapperDto,ComplaintsListResponseDto, etc. - Query parameter types:
FindResidentsParams,FindNoticesParams,FindPollsParams, etc. - Enum/Union types:
UserRole,JoinStatus,ComplaintStatus,PollStatus, etc. - Common types:
MessageResponseDto,ErrorResponse,PaginatedResponse, etc.
Note: If you need a type that's not exported, add it to @/lib/types/index.ts rather than importing from @/lib/types/api.
For complete type catalog: See 3_openapi-typescript.md