AI Skill Report Card

Creating PATCH Controllers

B+75·May 6, 2026·Source: Web
15 / 15
TypeScript
export const updateUserController = async ( id: User['id'], params: UpdateUserParams, ): Promise<AxiosResponse<User, any>> => { const url = `/api/users/${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
Remove the Portuguese error messages ('Erro na requisição:') and make examples language-neutral
12 / 15
  1. Function signature: export const update{Entity}Controller = async (
  2. Parameters: Add URL parameters first (0-M), then body params
  3. Return type: Promise<AxiosResponse<ReturnType, any>>
  4. URL construction: /api/{module}/{urlParams}/{entity-id}/
  5. Request execution: Use instance.patch(url, params)
  6. Error handling: Standard try/catch with console.error

Progress checklist:

  • Define entity and operation name
  • Identify URL parameters (path segments)
  • Define body parameter type
  • Define response entity type
  • Construct URL pattern
  • Implement standard error handling
Recommendation
Add information about the genRequestInstance() function or how to configure the Axios instance
20 / 20

Example 1 - Single ID parameter: Input: Entity "Product", single ID, body type "UpdateProductParams", return "Product" Output:

TypeScript
export const updateProductController = async ( id: Product['id'], params: UpdateProductParams, ): Promise<AxiosResponse<Product, any>> => { const url = `/api/products/${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 - Multiple URL parameters: Input: Entity "Task", URL params "projectId" and "taskId", body "UpdateTaskParams", return "Task" Output:

TypeScript
export const updateTaskController = async ( projectId: Project['id'], taskId: Task['id'], params: UpdateTaskParams, ): Promise<AxiosResponse<Task, any>> => { const url = `/api/projects/${projectId}/tasks/${taskId}/`; 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 3 - No URL parameters: Input: Entity "Settings", no URL params, body "UpdateSettingsParams", return "Settings" Output:

TypeScript
export const updateSettingsController = async ( params: UpdateSettingsParams, ): Promise<AxiosResponse<Settings, any>> => { const url = `/api/settings/`; 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
Include examples of the UpdateParams interfaces and explain partial update patterns vs full replacement
  • Function naming: Always use update{Entity}Controller pattern
  • Parameter order: URL parameters first (in path order), body params last
  • Type safety: Use entity type references (Entity['id']) for IDs
  • URL format: Follow REST convention /api/{resource}/{id}/ with trailing slash
  • Error logging: Always log errors with 'Erro na requisição:' prefix
  • Consistent spacing: Two blank lines between controller functions
  • Don't mix parameter order - URL params always come before body
  • Don't forget trailing slash in URLs
  • Don't use generic error messages - keep "Erro na requisição:" standard
  • Don't handle errors beyond logging and rejecting - let Axios handle status codes
  • Don't use any for body or response types - always define specific interfaces
0
Grade B+AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
15/15
Workflow
12/15
Examples
20/20
Completeness
0/20
Format
15/15
Conciseness
13/15