AI Skill Report Card
Generating TypeScript REST API
Quick Start8 / 15
I'll help you generate a TypeScript API POST function. First, I need some information:
1. What is the resource/function name? (e.g., "createArea", "updateUser", "processPayment")
2. What are the URL parameters?
Format as TypeScript object properties (e.g., versao: string, id?: number). Leave blank if none.
3. What is the BODY type? Paste the TypeScript interface/type for the request body.
4. What is the RETURN type? Paste the TypeScript interface/type for the response data.
Recommendation▾
Remove the 'I'll help you generate...' opening and jump straight to the requirements list - Claude doesn't need to introduce itself
Workflow12 / 15
Progress:
- Collect function requirements
- Generate main controller function with JSDoc
- Generate unit tests
- Add error handling patterns
- Validate TypeScript types
Step-by-step Process:
- Analyze parameters - Determine if URL params needed
- Structure function signature - Single params object if URL params exist
- Build URL path - Template literals for dynamic segments
- Add error handling - Try-catch with proper error propagation
- Generate tests - Success and error scenarios
- Add JSDoc - Complete documentation
Recommendation▾
The Quick Start asks for information but doesn't provide immediate actionable content - include a basic example that works right away
Examples18 / 20
Example 1: No URL Parameters Input:
- Name: "createArea"
- URL params: (none)
- Body:
CreateAreaParams - Return:
Area
Output:
TypeScript/** * Creates a new area * @param body - Area creation parameters * @returns Promise with area creation response * @throws {Error} When request fails */ export const createAreaController = async ( body: Planejamento.Cadastro.Area.CreateAreaParams, ): Promise<AxiosResponse<Planejamento.Cadastro.Area.Area, any>> => { const url = '/api/planejamento/area/'; const instance = genRequestInstance(); try { const response = await instance.post(url, body); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Example 2: With URL Parameters Input:
- Name: "createColaboradorVaga"
- URL params:
versao: string - Body:
CreateColaboradorVagaParams - Return:
any
Output:
TypeScript/** * Creates a new colaborador vaga for specific version * @param params - URL parameters containing version ID * @param body - Colaborador vaga creation parameters * @returns Promise with creation response * @throws {Error} When request fails */ export const createColaboradorVagaController = async ( params: { versao: Planejamento.Versao.Versao['id'] }, body: Pessoal.Colaborador.Vaga.CreateColaboradorVagaParams, ): Promise<AxiosResponse<any, any>> => { const url = `/api/pessoal/versao/${params.versao}/colaborador-vaga/`; const instance = genRequestInstance(); try { const response = await instance.post(url, body); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Recommendation▾
Add the promised unit test examples in the Examples section - currently only shows controller functions but mentions test generation in workflow
Best Practices
- Single params object for URL parameters when they exist
- Consistent naming ending with "Controller"
- Proper TypeScript generics for AxiosResponse
- Template literals for dynamic URL construction
- Error logging before rejection
- JSDoc documentation for all parameters and returns
- Namespace typing following project patterns
Common Pitfalls
- Don't use query strings - All parameters go in URL path
- Don't make params optional when URL segments required
- Don't skip error handling - Always wrap in try-catch
- Don't forget trailing slashes in URL paths
- Don't mix param styles - Use object destructuring consistently
- Don't omit JSDoc - Documentation is mandatory
Please provide the 4 pieces of information above, and I'll generate your complete TypeScript API function with tests!