mbus-backend
    Preparing search index...

    Function addPostRoute

    • Wrapper around router.post with built in validation and schema recording, more details can be found in addGetRoute.

      Type Parameters

      • P extends StringlyZodObject

        path params

      • Q extends StringlyZodObject

        query params

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

        request body

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

        response body

      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; reqBody: B; 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>,
            body: output<B>,
        ) => 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.post internally, to be used in testing