Ir al contenido

Http action naming (ARCH3004)

Esta página aún no está disponible en tu idioma.

Key typescript.naming.route-handler-naming · Severity info · Category naming

Web framework route handler / controller action names should reflect their HTTP verb semantics (GET → get/list, POST → create). Mismatched names hurt API readability and RESTful consistency.

@Controller("users")
class UserController {
@Get()
createUsers() { return this.svc.findAll(); }
@Post()
getUser(@Body() dto: CreateUserDto) { return this.svc.create(dto); }
}
@Controller("users")
class UserController {
@Get()
listUsers() { return this.svc.findAll(); }
@Post()
createUser(@Body() dto: CreateUserDto) { return this.svc.create(dto); }
}

Rename the action to match the HTTP verb: get/list for GET, create for POST, update for PUT, delete for DELETE.