From ae03ab0c0f4adb2e64aa96f36e76399cdfa53ae6 Mon Sep 17 00:00:00 2001 From: ByungJoon Lee Date: Mon, 5 Feb 2024 22:39:30 +0900 Subject: [PATCH] feat(generator): change method character that is always lowercase --- examples/handlers/avengers/heroes/get.ts | 7 +++++++ src/compilers/routes/getRouteHandler.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 examples/handlers/avengers/heroes/get.ts diff --git a/examples/handlers/avengers/heroes/get.ts b/examples/handlers/avengers/heroes/get.ts new file mode 100644 index 0000000..d33d57d --- /dev/null +++ b/examples/handlers/avengers/heroes/get.ts @@ -0,0 +1,7 @@ +import type { HTTPMethods } from 'fastify'; + +export const methods: HTTPMethods = 'SEARCH'; + +export async function handler() { + return 'hello'; +} diff --git a/src/compilers/routes/getRouteHandler.ts b/src/compilers/routes/getRouteHandler.ts index 1b68636..2844357 100644 --- a/src/compilers/routes/getRouteHandler.ts +++ b/src/compilers/routes/getRouteHandler.ts @@ -12,6 +12,7 @@ import { validatePropertySignature } from '#/compilers/validators/validateProper import { validateTypeReferences } from '#/compilers/validators/validateTypeReferences'; import type { IBaseOption } from '#/configs/interfaces/IBaseOption'; import { getImportConfigurationFromResolutions } from '#/generators/getImportConfigurationFromResolutions'; +import type { CE_ROUTE_METHOD } from '#/routes/const-enum/CE_ROUTE_METHOD'; import { getExtraMethod } from '#/routes/extractors/getExtraMethod'; import { getRouteMap } from '#/routes/extractors/getRouteMap'; import type { IRouteConfiguration } from '#/routes/interfaces/IRouteConfiguration'; @@ -79,7 +80,7 @@ export async function getRouteHandler( ); const routeConfiguration: IRouteConfiguration = { - methods: [routePathConfiguration.method, ...extraMethods], + methods: [routePathConfiguration.method, ...extraMethods].map((method) => method.toLowerCase() as CE_ROUTE_METHOD), routePath: routePathConfiguration.routePath, hash, hasOption: routeOptions.has.option,