The router middleware for PXE.js.
Install @pxe/router.
# NPM
npm i @pxe/router
# Yarn
yarn add @pxe/router
All the router methods, event and declarations.
Routerroot?: string: The root URLConstruct a router. The root is used to run the middlewares if the request URL starts with the root URL.
router.use...m: Middleware[]: The middlewareAdd a middleware to the middleware list. You can add multiple middleware within a single call.
route.handleroute: string: The target route path namehandler: Router.RouteHandler: The route handlerRegister a handler for a specific path name.
route.paramroute: string: The target route path namehandler: Router.RouteHandler: The route handlerThe same as route.param, but instead handles dymanic routes.
route.invokectx: Server.Context: The server contextnext: Server.NextFunction: Call the next middleware...args: any[]: The previous middleware passed argumentsThe callback of the router. This can be used as a middleware:
app.use(router.invoke.bind(router));
// Or shorter
app.use(router);