• A class decorator that defines the router used by controllers

    Parameters

    • container: {} = defaultContainer

      Object that stores injectables

      Returns ClassDecorator<Class<AnnotatedRouter>>

      Remarks

      @Router annotates the class that will handle incoming requests

      See

      AnnotatedRouter for interface definition

      Example

      import { AnnotatedRouter, Router } from "@fork-git-it/annotatedjs";

      @Router()
      export class ExampleRouter implements AnnotatedRouter {
      get(uri: string, handler: RequestHandler): AnnotatedRouter {
      // configure router to handle GET request
      return this;
      }

      put(uri: string, handler: RequestHandler): AnnotatedRouter {
      // configure router to handle PUT request
      return this;
      }

      post(uri: string, handler: RequestHandler): AnnotatedRouter {
      // configure router to handle POST request
      return this;
      }

      patch(uri: string, handler: RequestHandler): AnnotatedRouter {
      // configure router to handle PATCH request
      return this;
      }

      delete(uri: string, handler: RequestHandler): AnnotatedRouter {
      // configure router to handle DELETE request
      return this;
      }

      all(uri: string, handler: RequestHandler): AnnotatedRouter {
      // configure router to handle all requests
      return this;
      }

      handle(req: Request): Promise<Response> {
      // handle incoming request using the router
      }
      }

    Generated using TypeDoc