This is a generic class to provide middleware for Browse/Read/Edit/Add/Delete operations and forms. It comes with some baked-in pre-flight checks but needs to be extended to do useful work. All default actions except reads require being logged in.

Use the bakery method to create standard BREAD routes. :)

Hierarchy (View Summary)

Indexable

  • [key: string]: unknown

Constructors

  • Parameters

    • req: ProviderRequest

      Express request

    • res: ProviderResponse

      Express response

    • next: NextFunction

      Express callback to move on to next middleware

    • options: ProviderOptions = {}

      What kind of route to create

      • action='add'

        one of 'browse', 'read' (view), 'add' (create), 'edit', 'delete'

      • method='GET'

        what HTTP method this route responds to

      • id

        if required, what object ID to look up

      • someOtherID

        will also be assigned to this

    Returns default

Properties

action: string
actions: Record<string, BreadAction<unknown>>
getResourceErrorHandler: (
    messageKeyPrefix: string,
    bodyParam: string,
) => (error: unknown) => void
id?: string
messageKeyPrefix: string
method: string
next: NextFunction
renderPermissionError: BoundRenderFunction
renderResourceError: BoundRenderFunction
renderSigninRequired: BoundRenderFunction
renderTemplate: BoundTemplateRenderer
req: ProviderRequest
res: ProviderResponse

Methods

  • Parameters

    • resourceKeyPrefix: string
    • OptionalresourceID: string
    • Optionalmessage: string

    Returns void