• Initialize the framework

    Parameters

    • container: {} = defaultContainer

      Object that stores injectables

      Returns RequestHandler

      Remarks

      AnnotatedJS starts with the initialize() method

      This method will return back a request handler. The request handler can then be used in different runtimes such as a service worker, or node

      Example

      // service worker entrypoint

      import { initialize } from "@fork-git-it/annotatedjs";
      // import annotated classes

      const handleRequest = initialize();
      const eventHandler = (evt: Event) => {
      evt.respondWith(handleRequest(evt.request));
      };
      addEventListener("fetch", eventHandler);
      // node entrypoint

      import { initialize } from "@fork-git-it/annotatedjs";
      import { createServerAdapter } from "@whatwg-node/server";
      import { createServer } from "http";
      import "isomorphic-fetch";
      // import annotated classes

      const handleRequest = initialize();
      const ittyServer = createServerAdapter(handleRequest);
      const httpServer = createServer(ittyServer);
      httpServer.listen(3001);
      console.log("listening at https://localhost:3001");

    Generated using TypeDoc