
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
fast-router
Advanced tools
A fast & simple O(1) URL router for node.js that can be used for almost anything.
A fast & simple O(log n) URL router for node.js that can be used for almost anything.
Runtime: O(log n), where n is the total number of routes. The runtime is O(n) if you consider n the length of your longest route.
//Require the module...
var Router = require("fast-router").Router;
//Create a new router
var router = new Router();
That's all. Now you can begin to add routes:
router.addRoute("/", rootNode);
router.addRoute("/users/:user/:thing", someValue);
//Keys are used and indicated by ':' . They will capture that part in the URL.
router.addRoute("/static/*", someOtherValue);
//A wildcard is indicated by a '*' and will capture the rest of the URL
router.addRoute("/static/robots.txt", specialMagic);
//Exact matches always take precendence over wildcards and paths with keys
To match some URL against the route tree:
var result = router.parse("/users/tim/lamp");
var result = router.parse("/static/main/js/local/script.js");
var result = router.parse("/");
A result is a javascript object with the following properties:
{
url: <url>,
//contains the URL as parsed with node.js's built-in url.parse(_url, true)
value: <value>,
//The value that was supplied when the route was inserted. You could use
//a function for it to emulate the behavior of some other routers.
parts: [...],
//The parts of the URL as the result of url.pathname.split('/')
keys: {key: value, ...},
//The keys used in the URL with their respective values,
//for the first example this would be {user: "tim", thing: "lamp"}
extra: "<etc>/<etc>/<etc>..."
//The text matched by the wildcard if the route contained one
}
FAQs
A fast & simple O(1) URL router for node.js that can be used for almost anything.
We found that fast-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.