serwist
Version:
A Swiss Army knife for service workers.
41 lines • 1.47 kB
TypeScript
import { Router } from "./Router.js";
/**
* Creates a new, singleton {@linkcode Router} if one does not exist. If one does
* already exist, that instance is returned. This instance is used by
* Serwist's {@linkcode Router}-dependent functions and classes unless you provide
* a different {@linkcode Router} to them.
*
* @returns The singleton {@linkcode Router}.
* @deprecated
*/
export declare const getSingletonRouter: () => Router;
/**
* Changes the singleton {@linkcode Router} to a different instance. This is meant for when you do not
* want to pass your own {@linkcode Router} to every one of Serwist's {@linkcode Router}-dependent functions and classes.
* If this or {@linkcode getSingletonRouter} has been called before, it removes the listeners of the
* previous singleton {@linkcode Router}. It also adds those of the new one, so you need not do that yourself.
*
* It is highly recommended that you call this before anything else, if you plan on doing so.
*
* @example
* ```js
* import { Router, setSingletonRouter } from "serwist/legacy";
*
* const router = new Router();
*
* setSingletonRouter(router);
*
* router.registerRoute(
* new Route(
* /\/api\/.*\/*.json/,
* new NetworkOnly(),
* "POST",
* ),
* );
* ```
* @param router
* @returns The new singleton {@linkcode Router}.
* @deprecated
*/
export declare const setSingletonRouter: (router: Router) => Router;
//# sourceMappingURL=singletonRouter.d.ts.map