Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@bicycle-codes/routes
Advanced tools
Route matcher devised for shared rendering JavaScript applications
Route matcher devised for shared rendering JavaScript applications
npm install -S @bicycle-codes/routes
Featuring ESM or CJS versions via package.json
exports
field.
// esm
import Router from '@bicycle-codes/routes'
// cjs
const Router = require('@bicycle-codes/routes').default
Get a router instance
import Router from '@bicycle-codes/routes'
var router = new Router()
router.addRoute('/articles', getArticles);
router.addRoute('/articles/:slug', getArticleBySlug);
router.addRoute('/articles/search/*', searchForArticles);
// can also chain the method calls
router
.addRoute('/foo', () => {/* ... */})
.addRoute('/bar', () => {/* ... */})
const match = router.match('/articles');
// => RouteMatch
interface RouteMatch {
params:Record<string, string>; // <-- e.g. { slug: 'article-title' }
splats:string[];
route:string;
next?:((...any)=>any)|null;
action?:(...any)=>any;
index?:number;
}
You'll get null
back if no route matches the provided URL. Otherwise, the
route match will provide all the useful information you need inside an object.
Key | Description |
---|---|
action | The action passed to addRoute as a second argument. Using a function is recommended |
next | Fall through to the next route, or null if no other routes match |
route | The route passed to addRoute as the first argument |
params | An object containing the values for named parameters in the route |
splats | An object filled with the values for wildcard parameters |
MIT
This is a fork of ruta3, just adding types.
FAQs
Route matcher devised for shared rendering JavaScript applications
The npm package @bicycle-codes/routes receives a total of 129 weekly downloads. As such, @bicycle-codes/routes popularity was classified as not popular.
We found that @bicycle-codes/routes 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.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.