
Product
Microsoft Teams Notifications Are Now Available in Socket
Socket can now send alerts and supply chain attack notifications to Microsoft Teams, with filters that route the right updates to each channel.
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 29,152,688 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.

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.

Security News
Socket CTO Ahmad Nassri joins AppSec leaders at Black Hat to discuss active malware, package manager risks, and software supply chain defense.