mbus-backend
    Preparing search index...

    Function addGetRoute

    • Wrapper around router.get with built in validation and schema recording

      The req and res objects aren't provided to the passed in handler, if you're doing something more complicated (e.g. using headers) just use the router directly for now, the functionality needed could be incorporated in the future.

      Type Parameters

      • P extends StringlyZodObject

        path parameters as a zod object

      • Q extends StringlyZodObject

        query parameters as a zod object

      • RB extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

        response body as a zod type

      Parameters

      • ctx: ReflectionInfoRaw

        which context to place this route in, see globalContext

      • router: Router

        express router

      • path: string

        path the route happens, same format as used in express but avoid features not supported in openapi (e.g. advanced path matchers)

      • format: { params: P; query: Q; resBody: RB }

        zod schemas of the parts of the request and response, use emptyFormat to fill in default values

      • handler: (params: output<P>, query: output<Q>) => HandlerReturn<output<RB>>

        route handler

      • Optionaldocs: { description?: string; summary?: string }

        information that should end up in the openapi spec

        • Optionaldescription?: string

          a longer explanation, commonmark accepted

        • Optionalsummary?: string

          a short description of what is route does, becomes the title

      Returns (
          req: ExpressRequest,
      ) => { json: output<RB> | { error: string }; status: number }

      the handler function that got passed to router.get internally, to be used in testing