AI Skill Report Card

Creating TypeScript Controller

B-72·May 6, 2026·Source: Web
13 / 15
TypeScript
export const create{EntityName}Controller = async ( body: {Namespace}.{EntityName}.Create{EntityName}Params, ): Promise<AxiosResponse<{Namespace}.{EntityName}.{EntityName}, any>> => { const url = '/api/{endpoint}/'; 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 template sections for different controller patterns (with/without path params, different namespaces) to provide clear frameworks
12 / 15

Progress:

  • Identify entity name and required parameters
  • Check for existing typings in typings.d.ts
  • Determine URL structure and path parameters
  • Generate JSDoc documentation
  • Create controller function with proper typing
  • Add error handling pattern

Step-by-step Process

  1. Extract entity information

    • Entity name (PascalCase)
    • Namespace hierarchy
    • Required path parameters
  2. Verify typings exist

    • Create{EntityName}Params interface
    • {EntityName} response interface
    • Ask user if missing
  3. Build URL pattern

    • Base: /api/{module}/{endpoint}/
    • With params: /api/{module}/versao/${versao}/{endpoint}/
  4. Generate function

    • Function name: create{EntityName}Controller
    • Parameters: path params + body
    • Return type: Promise<AxiosResponse<EntityType, any>>
Recommendation
Include edge cases like handling multiple path parameters, optional parameters, or different HTTP status codes
18 / 20

Example 1: Controller with path parameter Input: "Create controller for AdicionalNoturno with versao parameter" Output:

TypeScript
/** * Creates a new AdicionalNoturno * @param versao - Version ID for the planning * @param params - AdicionalNoturno creation parameters * @returns Promise with AdicionalNoturno response * @throws Error when request fails */ export const createAdicionalNoturnoController = async ( versao: Planejamento.Versao.Versao['id'], params: Pessoal.Premissas.AdicionalNoturno.CreateAdicionalNoturnoParams, ): Promise< AxiosResponse<Pessoal.Premissas.AdicionalNoturno.AdicionalNoturno, any> > => { const url = `/api/pessoal/versao/${versao}/adicional-noturno/`; const instance = genRequestInstance(); try { const response = await instance.post(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };

Example 2: Simple controller without parameters Input: "Create controller for Area entity" Output:

TypeScript
/** * Creates a new Area * @param body - Area creation parameters * @returns Promise with Area 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); } };
Recommendation
Provide default URL patterns and namespace structures to avoid requiring user input for common cases
  • Always use genRequestInstance() for authenticated requests
  • Include JSDoc with @param, @returns, and @throws
  • Follow naming convention: create{EntityName}Controller
  • Path parameters come before body parameter
  • Use kebab-case for URL endpoints
  • Maintain consistent error handling pattern
  • Don't assume typings exist - always verify or ask
  • Don't change the established error handling pattern
  • Don't mix camelCase with kebab-case in URLs
  • Don't omit JSDoc documentation
  • Don't modify the axios instance configuration
0
Grade B-AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
13/15
Workflow
12/15
Examples
18/20
Completeness
4/20
Format
13/15
Conciseness
12/15