|
| 1 | +## Project Overview |
| 2 | +- Package: `@procoders/astrology-api-client` |
| 3 | +- Purpose: TypeScript SDK for https://api.astrology-api.io (OpenAPI spec saved in `docs-openapi.json`) |
| 4 | +- Runtime: Node.js (ES modules) |
| 5 | +- HTTP layer: Axios with request/response interceptors, automatic retry logic, strict validation |
| 6 | +- Tests: Vitest with 100% coverage enforced (`npm run test:coverage`) |
| 7 | + |
| 8 | +## Directory Layout |
| 9 | +- `src/client.ts` — core client implementation |
| 10 | +- `src/types/` — strongly typed configs, requests, and responses |
| 11 | +- `src/errors/` — custom error hierarchy (`AstrologyError`) |
| 12 | +- `src/utils/validators.ts` — runtime validation helpers used prior to network calls |
| 13 | +- `tests/` — unit tests with axios-mock-adapter (keep coverage at 100%) |
| 14 | +- `examples/usage.ts` — sample usage (guarded by `RUN_ASTROLOGY_EXAMPLE` flag) |
| 15 | +- `docs-openapi.json` — locally cached OpenAPI v3 spec (use for type references) |
| 16 | + |
| 17 | +## Coding Guidelines |
| 18 | +- Always prefer type-safe solutions; keep files in strict TypeScript. |
| 19 | +- Keep code DRY, KISS, and single-responsibility. Extract helpers if logic repeats. |
| 20 | +- Comments, docs, and logs MUST be written in English. |
| 21 | +- When adding HTTP endpoints ensure: |
| 22 | + - URL assembled via RapidAPI base URL (default from `DEFAULT_RAPIDAPI_HOST`) |
| 23 | + - RapidAPI headers are set (`x-rapidapi-key`, `x-rapidapi-host`) |
| 24 | + - Environment variables: `RAPIDAPI_KEY`, `RAPIDAPI_HOST`, `ASTROLOGY_API_BASE_URL` |
| 25 | + - Payload validated via `validators.ts`. |
| 26 | +- For additions touching API schema, consult `docs-openapi.json` first. |
| 27 | +- Update or add Vitest suites and maintain 100% coverage. Use axios-mock-adapter for HTTP mocks. |
| 28 | +- Run `npm run lint` and `npm run test:coverage` before completion. |
| 29 | + |
| 30 | +## Documentation & Examples |
| 31 | +- README must show installation, configuration, environment variables, and code snippets. |
| 32 | +- When adding examples, wrap network calls with environment checks so examples do not run by default. |
| 33 | + |
| 34 | +## Tooling |
| 35 | +- ESLint + Prettier already configured; match formatting in existing files. |
| 36 | +- Coverage enforced in `vitest.config.ts`. If coverage drops, add tests instead of raising thresholds. |
| 37 | + |
| 38 | +## PR / Commit Checklist |
| 39 | +1. Update relevant types in `src/types/`. |
| 40 | +2. Keep public API exported via `src/index.ts`. |
| 41 | +3. Add/adjust tests to maintain 100% coverage. |
| 42 | +4. Document new features in README. |
| 43 | +5. Ensure `.cursorrules` stays aligned with architecture changes. |
| 44 | + |
0 commit comments