AI Skill Report Card

Creating TypeScript Update Controllers

B+78·May 6, 2026·Source: Web
15 / 15
TypeScript
export const updateEntityController = async ( id: Entity.Entity['id'], params: Entity.UpdateEntityParams, ): Promise<AxiosResponse<Entity.Entity, any>> => { const url = `/api/entity/${id}/`; const instance = genRequestInstance(); try { const response = await instance.patch(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Recommendation
Add a template section with placeholders for entity name, parameters, and types to make generation more systematic
12 / 15
  1. Identify entity and parameters

    • Entity name (for function naming)
    • Entity ID type
    • Additional URL parameters (if any)
    • Update payload type
  2. Generate function signature

    • Function name: update{EntityName}Controller
    • Parameters: additional params first, then entity ID, then update payload
    • Return type: AxiosResponse<EntityType, any>
  3. Build URL pattern

    • Base: /api/module/entity/${id}/
    • With parameters: /api/module/versao/${versao}/entity/${id}/
  4. Add JSDoc documentation

    • @param for each parameter
    • @returns for response type
    • @throws for error cases
Recommendation
Include validation patterns and error handling strategies beyond basic try-catch
20 / 20

Example 1 (Simple entity): Input: Entity "User", no additional parameters

TypeScript
/** * Updates a user entity * @param id - User ID * @param params - Update parameters * @returns Promise with user data response * @throws Error if request fails */ export const updateUserController = async ( id: User.User['id'], params: User.UpdateUserParams, ): Promise<AxiosResponse<User.User, any>> => { const url = `/api/user/${id}/`; const instance = genRequestInstance(); try { const response = await instance.patch(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };

Example 2 (With additional parameters): Input: Entity "Funcionario" with "empresaId" parameter

TypeScript
/** * Updates a funcionario entity within a specific empresa * @param empresaId - Empresa ID * @param id - Funcionario ID * @param params - Update parameters * @returns Promise with funcionario data response * @throws Error if request fails */ export const updateFuncionarioController = async ( empresaId: Empresa.Empresa['id'], id: Funcionario.Funcionario['id'], params: Funcionario.UpdateFuncionarioParams, ): Promise<AxiosResponse<Funcionario.Funcionario, any>> => { const url = `/api/empresa/${empresaId}/funcionario/${id}/`; const instance = genRequestInstance(); try { const response = await instance.patch(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Recommendation
Provide guidance on testing these controllers, including mock examples and common test scenarios
  • Function naming: Always use update{EntityName}Controller format
  • Parameter order: Additional URL params first, entity ID second, update payload last
  • URL structure: Follow REST conventions with clear hierarchy
  • Type safety: Use proper TypeScript namespacing for entity types
  • Error handling: Use consistent error logging and rejection
  • JSDoc: Include comprehensive documentation for all parameters
  • Wrong parameter order: Entity ID should come after additional URL parameters
  • Missing JSDoc: Always document parameters and return types
  • Incorrect URL structure: Ensure URL matches the API endpoint pattern
  • Type mismatches: Verify that entity types exist in typings.d.ts before using
  • Missing async/await: Controller functions must be async
0
Grade B+AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
15/15
Workflow
12/15
Examples
20/20
Completeness
4/20
Format
15/15
Conciseness
12/15