MCPcopy Create free account
hub / github.com/blockmatic/basilic / extractModuleFromRoute

Function extractModuleFromRoute

apps/api/src/plugins/error-handler.ts:21–29  ·  view source on GitHub ↗

* Extracts module name from route path * Examples: /users/123 → 'user-service', /payments → 'payment-service'

(routePath: string)

Source from the content-addressed store, hash-verified

19 const resource = match[1]
20 const singular = pluralExceptions[resource] ?? resource.replace(/s$/, '')
21 return `${singular}-service`
22}
23
24const errorHandler: FastifyPluginAsync = async fastify => {
25 fastify.setErrorHandler((error: FastifyError, request, reply) => {
26 const routePath: string =
27 'routerPath' in request && typeof request.routerPath === 'string'
28 ? request.routerPath
29 : (request.url.split('?')[0] ?? '/')
30
31 const module = extractModuleFromRoute(routePath) ?? 'api-route'
32 const statusCode: number =

Callers 1

error-handler.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected