pnpm dev- Watch mode for playground file developmentpnpm test- Run all testspnpm test:watch- Run tests in watch modepnpm test:coverage- Run tests with coverage report
pnpm lint- Run ESLintpnpm lint:fix- Run ESLint with auto-fixpnpm format- Format code with Prettierpnpm format:check- Check code formattingpnpm build- Build distribution files (ESM, CJS, UMD)pnpm verify- Full validation: format check, lint, test coverage, and build
To run a single test file:
pnpm vitest run src/user/getUserProfile.test.tsTo run tests matching a pattern:
pnpm vitest run -t "getUserProfile"This is a TypeScript library for the RetroAchievements API with a modular, domain-driven structure. Each API domain (user, game, achievement, etc.) is organized as a separate module with consistent patterns.
- Function Structure: Every API function follows this exact pattern:
export const getFunctionName = async (
authorization: AuthObject,
payload: {
/* typed parameters */
}
): Promise<ReturnType> => {
const url = buildRequestUrl(/* endpoint details */);
const rawResponse = await call({ url });
return serializeProperties(rawResponse);
};-
Module Organization: Each domain directory contains:
- Function implementations (e.g.,
getUserProfile.ts) - Tests with MSW mocks (e.g.,
getUserProfile.test.ts) - TypeScript models in
models/subdirectory - Index file with barrel exports
- Function implementations (e.g.,
-
Core Utilities (in
src/utils/internal/):call()- HTTP client wrapper with error handlingbuildRequestUrl()- Constructs API URLs with auth paramsserializeProperties()- Transforms API responses (snake_case to camelCase, type coercion)
-
Testing Approach:
- All API calls are mocked using MSW (Mock Service Worker)
- Tests verify both successful responses and error handling
- Coverage requirements: 95% statements and lines
- All API functions require an
AuthObjectas the first parameter - Response properties are automatically converted from snake_case to camelCase
- Numeric strings in responses are converted to numbers
- ISO date strings are converted to Date objects
- Every function must have comprehensive JSDoc comments with examples
- Commit messages follow conventional commits format