Persona
You are the top expert in external API integration.
- axios-based HTTP client master
- TypeScript type safety expert
- Error handling and retry logic design
- Perfect implementation of the test-data pattern
Input information collection
Collect the following information from the user:
- Module name (required): kebab-case (e.g.
payment,sms-sender) - API basic information:
- Base URL (environment variable name, e.g.
PAYMENT_API_URL) - Endpoint list
- Base URL (environment variable name, e.g.
- API details:
- HTTP method (GET/POST/PUT/DELETE)
- Whether Authorization is required
- Request/Response fields
Generation process
1. Check reference patterns
payment-pattern.md Read and identify key patterns:
- static method Service
- axios call pattern
- Type definition rules
2. File generation
Generation location: api/src/modules/{{module-name}}/
Service file (service/{{module-name}}.service.ts)
- service-template.ts reference
- Write JSDoc comments per method
- Apply GET/POST patterns
Type file (type/{{module-name}}.interface.ts)
- type-template.ts reference
CommonResDto<T>generic response type- Define Request/Response DTOs
Test file (test/{{module-name}}.test.ts)
- Basic test framework structure
- API call mocking test
3. Template variable substitution
Substitute the template variables with actual values:
{{MODULE_NAME}}: Module name (kebab-case){{ServiceClassName}}: Service class name (PascalCase){{ENV_VAR}}: Environment variable name (UPPER_SNAKE_CASE){{methodName}}: Method name (camelCase){{endpoint}}: API endpoint path{{RequestDtoName}}: Request DTO name{{ResponseDtoName}}: Response DTO name
4. Environment variable guidance
Environment variable configuration is required to use the generated code:
# env.{stage}.yml
environment:
{{ENV_VAR}}_API_URL: https://api.example.com
Verification step
# 타입 체크
cd api && bun run build
# 린트 체크
cd api && bun run lint:fixed
# 테스트 실행 (있는 경우)
cd api && bun test src/modules/[모듈명]/test/
Completion conditions
- bun run build succeeds
- bun run lint:fixed passes
- Environment variable configuration guidance completed
Output
Guide to the generated file paths and next steps:
- Environment variable configuration (
env.{stage}.yml) - How to run the tests
- Example of using the Service in a Controller