Naming conventions for methods, functions, and open api operations #115
Replies: 2 comments 4 replies
-
I think we should also consider the Examining an example controller and kubb zod + type, we can see how this may be structured. The code below currently exists on main. It has a zod schema of code on main @Get("/:bbl/geojson")
@UsePipes(new ZodValidationPipe(getTaxLotGeoJsonByBblPathParamsSchema))
async findTaxLotByBblGeoJson(
@Param() params: GetTaxLotGeoJsonByBblPathParams,
) {
return this.taxLotService.findTaxLotByBblGeoJson(params.bbl);
} possible refactor @Get("/:bbl/geojson")
@UsePipes(new ZodValidationPipe(findTaxLotByBblGeoJsonPathParamsSchema))
async findByBblGeoJson(
@Param() params: FindTaxLotByBblGeoJsonPathParams,
) {
return this.taxLotService.findByBblGeoJson(params.bbl);
} There is also value in having an established mapping between the http method and the verb we want to use in the function names. One possible map (with inspiration from nestjs sample)
|
Beta Was this translation helpful? Give feedback.
-
One note on singular v plural. I agree with making the methods plural when they're lists/may contain several results. I like keeping the classes singular because, in my mind, they have similar conventions to database tables. |
Beta Was this translation helpful? Give feedback.
-
Description
Standardize the naming of methods, functions, and OpenAPI operations around some shared conventions.
tax lot
orborough
)findById
findZoningDistrictsByBbl
findZoningDistrictsByTaxLotBbl
bbl
when used within the tax lot domain but it would betaxLotBbl
in the OpenAPI documenationfindZoningDistrictsByBbl
when finding a list of zoning districts in the tax lot domainfindMany
when finding a list of boroughs in the borough domainzoningDistrictId
v.zoningDistrictUuid
has caused a bit of confusion.ZoningDistrictId
should be used because the name of the column isid
.uuid
is merely the current format; it does not reflect the meaning of the variable.taxLotBbl
is fine becausebbl
is the column name for the primary id of tax lots.findZoningDistrictsGeoJsonByBbl
findGeoJsonByBbl
findManyGeoJson
csv
Historical discussion
We should establish conventions around function names. The seed of this discussion is a comment on PR #114
Beta Was this translation helpful? Give feedback.
All reactions