
Security News
GPT-6 Astra Attempts Supply Chain Attacks Against Open Source Maintainers in Testing
GPT-6 Astra hits 100% on ExploitBench and finds zero-days autonomously, while independent tests reveal scope violations and monitoring gaps.
Lightweight and fast router for JavaScript.
Install:
# ✨ Auto-detect
npx nypm install rou3
Import:
ESM (Node.js, Bun, Deno)
import {
createRouter,
addRoute,
findRoute,
removeRoute,
findAllRoutes,
routeToRegExp,
NullProtoObj,
} from "rou3";
CDN (Deno and Browsers)
import {
createRouter,
addRoute,
findRoute,
removeRoute,
findAllRoutes,
routeToRegExp,
NullProtoObj,
} from "https://esm.sh/rou3";
Create a router instance and insert routes:
import { createRouter, addRoute } from "rou3";
const router = createRouter(/* options */);
addRoute(router, "GET", "/path", { payload: "this path" });
addRoute(router, "POST", "/path/:name", { payload: "named route" });
addRoute(router, "GET", "/path/foo/**", { payload: "wildcard route" });
addRoute(router, "GET", "/path/foo/**:name", {
payload: "named wildcard route",
});
Match route to access matched data:
// Returns { payload: 'this path' }
findRoute(router, "GET", "/path");
// Returns { payload: 'named route', params: { name: 'fooval' } }
findRoute(router, "POST", "/path/fooval");
// Returns { payload: 'wildcard route' }
findRoute(router, "GET", "/path/foo/bar/baz");
// Returns undefined (no route matched for/)
findRoute(router, "GET", "/");
[!IMPORTANT] Paths should always begin with
/.
[!IMPORTANT] Method should always be UPPERCASE.
compileRouter(router, opts?)Compiles the router instance into a faster route-matching function.
IMPORTANT: compileRouter requires eval support with new Function() in the runtime for JIT compilation.
Example:
import { createRouter, addRoute } from "rou3";
import { compileRouter } from "rou3/compiler";
const router = createRouter();
// [add some routes]
const findRoute = compileRouter(router);
const matchAll = compileRouter(router, { matchAll: true });
findRoute("GET", "/path/foo/bar");
compileRouterToString(router, functionName?, opts?)Compile the router instance into a compact runnable code.
IMPORTANT: Route data must be serializable to JSON (i.e., no functions or classes) or implement the toJSON() method to render custom code or you can pass custom serialize function in options.
Example:
import { createRouter, addRoute } from "rou3";
import { compileRouterToString } from "rou3/compiler";
const router = createRouter();
// [add some routes with serializable data]
const compilerCode = compileRouterToString(router, "findRoute");
// "const findRoute=(m, p) => {}"
Published under the MIT license.
Made by @pi0 and community 💛
🤖 auto updated with automd
FAQs
Lightweight and fast router for JavaScript.
The npm package rou3 receives a total of 24,096,761 weekly downloads. As such, rou3 popularity was classified as popular.
We found that rou3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
GPT-6 Astra hits 100% on ExploitBench and finds zero-days autonomously, while independent tests reveal scope violations and monitoring gaps.

Product
Socket can now send alerts and supply chain attack notifications to Microsoft Teams, with filters that route the right updates to each channel.

Security News
pnpm 12 rewrites the package manager in Rust, cutting install times by up to 90% while preserving pnpm 11 workflows and lockfiles.