AI Skill Report Card
Generating TypeScript Delete Controllers
Quick Start15 / 15
TypeScriptimport { genRequestInstance } from '@/request'; import { AxiosResponse } from 'axios'; export const deleteEntityController = async ( id: Entity['id'], ): Promise<AxiosResponse<null, any>> => { const url = `/api/module/entity/${id}/`; const instance = genRequestInstance(); try { const response = await instance.delete(url); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Recommendation▾
Add template or framework section with placeholder variables (e.g., {{entityName}}, {{moduleName}}) for easier generation
Workflow12 / 15
- Determine parameters - Extract entity ID and any additional parameters
- Build URL pattern - Follow
/api/module/[params]/entity/${id}/structure - Add imports - Include
genRequestInstanceandAxiosResponse - Generate function - Create controller with proper typing and error handling
- Add JSDoc - Document parameters, returns, and exceptions
Progress:
- Identify entity name and module
- Determine additional parameters beyond ID
- Construct URL pattern
- Generate function signature with types
- Add error handling and JSDoc
Recommendation▾
Include edge cases like handling entities with compound IDs or optional parameters
Examples17 / 20
Example 1: Input: Delete controller for "usuario" entity in "auth" module, no extra parameters Output:
TypeScript/** * Deleta um usuário * @param id - ID do usuário * @returns Promise com resposta da API * @throws Error quando a requisição falha */ export const deleteUsuarioController = async ( id: Auth.Usuario.Usuario['id'], ): Promise<AxiosResponse<null, any>> => { const url = `/api/auth/usuario/${id}/`; const instance = genRequestInstance(); try { const response = await instance.delete(url); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Example 2: Input: Delete controller for "folha" in "pessoal" module with "versao" parameter Output:
TypeScript/** * Deleta uma folha de pagamento * @param versao - ID da versão * @param id - ID da folha * @returns Promise com resposta da API * @throws Error quando a requisição falha */ export const deleteFolhaController = async ( versao: Planejamento.Versao.Versao['id'], id: Pessoal.Folha.Folha['id'], ): Promise<AxiosResponse<null, any>> => { const url = `/api/pessoal/versao/${versao}/folha/${id}/`; const instance = genRequestInstance(); try { const response = await instance.delete(url); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Recommendation▾
Expand completeness with more specific typing patterns and error response handling strategies
Best Practices
- URL structure: Always end with
/-/api/module/entity/${id}/ - Function naming: Use camelCase with "Controller" suffix
- Parameter order: Additional parameters first, entity ID last
- Error handling: Use try-catch with console.error and Promise.reject
- Type safety: Use proper namespace typing (
Module.Entity.Entity['id']) - JSDoc: Include @param for all parameters, @returns, and @throws
Common Pitfalls
- Don't forget trailing slash in URLs
- Don't mix up parameter order - ID should be last
- Don't omit error handling even though axios handles it
- Don't use generic types - use specific namespace typing
- Don't forget to import required dependencies
- Don't use kebab-case in function names - use camelCase