Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "RouteImpl"

Index

Interfaces

Functions

Functions

ExpressRouteImpl

  • Creates a RouteImpl instance that contains implementations of all methods of a route schema that can be mounted on an Express router.

    Example

    const TestRoute = ExpressRouteImpl(TestRouteSchema, {
      async get(data) {
        // Do stuff
    
        return {
          body: {
            message: `Testing, ${data.query.name}`
          }
        }
      }
    })

    You can mount the route directly onto an Express router with:

    const router = express.Router()
    
    TestRoute.mountOn(router)

    Type parameters

    Parameters

    • schema: RouteSchema<M>

      The route schema to implement.

    • implementations: MethodImpls<M, ExpressRequest, ExpressResponse>

      The implementations of the methods defined in the given route schema.

    Returns RouteImpl<M, ExpressRouter>

Generated using TypeDoc