gatex
    Preparing search index...

    Manages route grouping, middleware application, and automated registration for Express applications.

    Index

    Constructors

    • Creates an instance of GroupingProvider.

      Parameters

      • router: IRouter = ...

        The Express router instance to use. Defaults to a new Router.

      • path: string = "/"

        The base path for all routes registered through this provider instance. Defaults to '/'.

      • middlewares: RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[] = []

        An array of middleware functions to be applied to all routes in this group.

      Returns default

    Properties

    router: IRouter

    Accessors

    • set schemeErrorHandler(
          handler: (
              err: default,
              req: Request,
              res: Response,
              next: NextFunction,
          ) => void,
      ): void

      Comment here

      Parameters

      • handler: (err: default, req: Request, res: Response, next: NextFunction) => void

      Returns void

    Methods

    • Registers a DELETE route.

      Parameters

      • path: string | string[]

        The route path(s).

      • ...handlers: HandlersList

        A list of handlers, which can include middleware.

      Returns default

      The GroupingProvider instance for chaining.

      provider.delete('/users/:id', deleteUserHandler);
      
    • Finalizes the setup by mounting the main router and error handlers onto the provided Express application. This should be called after all routes are defined.

      Parameters

      • app: Application

        The Express application instance.

      Returns void

    • Registers a GET route.

      Parameters

      • path: string | string[]

        The route path(s).

      • ...handlers: HandlersList

        A list of handlers, which can include a validation schema and middleware.

      Returns default

      The GroupingProvider instance for chaining.

      provider.get('/health', (req, res) => res.send('OK'));
      provider.get('/users/:id', userSchema, getUserHandler);
    • Creates a new nested route group with flexible arguments.

      Can be called in multiple ways:

      • group((router) => { ... })
      • group('path', (router) => { ... })
      • group(middleware, (router) => { ... })
      • group('path', middleware, (router) => { ... })

      Parameters

      • ...args: GroupArgs

        The arguments for creating the group, which can include a path, middleware, and the callback function.

      Returns void

    • Registers a PATCH route.

      Parameters

      • path: string | string[]

        The route path(s).

      • ...handlers: HandlersList

        A list of handlers, which can include a validation schema and middleware.

      Returns default

      The GroupingProvider instance for chaining.

      provider.patch('/users/:id', userPatchSchema, patchUserHandler);
      

    post

    • post(path: string | string[], ...handlers: HandlersList): default

      Registers a POST route.

      Parameters

      • path: string | string[]

        The route path(s).

      • ...handlers: HandlersList

        A list of handlers, which can include a validation schema and middleware.

      Returns default

      The GroupingProvider instance for chaining.

      provider.post('/users', userCreateSchema, createUserHandler);
      
    • Registers a PUT route.

      Parameters

      • path: string | string[]

        The route path(s).

      • ...handlers: HandlersList

        A list of handlers, which can include a validation schema and middleware.

      Returns default

      The GroupingProvider instance for chaining.

      provider.put('/users/:id', userUpdateSchema, updateUserHandler);
      
    • Registers a repository, automatically creating RESTful routes based on its methods and decorator metadata.

      Parameters

      • repository: IRepository

        An instance of a class that implements IRepository.

      • Optionalpath: string

        Optional. Overrides the base path name defined by the @PathName decorator or the class name.

      Returns default

      The GroupingProvider instance for chaining.

    • Returns the Express router instance for the route group.

      Returns IRouter

      The Express router instance.

    • Uses a given router in the current route group.

      Parameters

      • router: Router

        The router to be used.

      Returns void