MCPcopy
hub / github.com/tinyhttp/tinyhttp / createMiddlewareFromRoute

Function createMiddlewareFromRoute

packages/router/src/index.ts:109–119  ·  view source on GitHub ↗
({
  path,
  handler,
  method
}: MethodHandler<Req, Res> & {
  method?: Method
})

Source from the content-addressed store, hash-verified

107/** HELPER METHODS */
108
109const createMiddlewareFromRoute = <Req extends any = any, Res extends any = any>({
110 path,
111 handler,
112 method
113}: MethodHandler<Req, Res> & {
114 method?: Method
115}) => ({
116 method,
117 handler: handler || (path as Handler),
118 path: typeof path === 'string' ? path : '/'
119})
120
121/**
122 * Push wares to a middleware array

Callers 1

pushMiddlewareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected