
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.
snow-router
Advanced tools
//use with pure http server or express middleware
const Router = require('snow-router')
var router = new Router()
router.get("**", (req, resp, next)=>{
console.log(1)
next()
})
router.get("/:a/:b", (req, resp, next)=>{
console.log(req.params)
resp.end()
})
//use with koa
router.get("**", (ctx, next)=>{
console.log(1)
next()
})
router.get("/:a/:b", (ctx, next)=>{
console.log(ctx.request.params)
resp.end()
})
//pure http server
_http.createServer(router.pure).listen(9999)
//koa
koaApp.use(router.koa)
//express
expressAPp.use(route.express)
use ** match one or more deep path,
e.g.
router.get("**", ()=>) # match all router
router.get("/a/**", ()=>) #match all router begin with `/a/` for example: /a/x, /a/xx/x/x/x
use * match one deep path
e.g.
router.get("*", ()=>) #just match /a, /b, /c, if path is `/a/b` , response 404
router.get("/a/*", ()=>) #just match /a/1, /a/b, /a/2, if path is `/a/b/1` , response 404
use:xxx will parse data to req.params
e.g.
//pure or express
router.get("/a/:id", async (request, response, next)=>{
console.log(request.params) // log is {id:1}
})
//koa
router.get("/a/:id", async (ctx, next)=>{
console.log(ctx.request.params) // log is {id:1}
})
all of above you can use chained calls e.g.
router.get("xxx", ()=>{})
.get("xxxx", ()=>{})
.post("xxx", ()=>{})
use chained calls:
router.url("/a").get((request, response, next)=>{}).post((request, response, next)=>{}).update(...).delete(...).all(...)
equals:
router.get("/a", ()=>{})
.post("/a", ()=>{})
.update("/a", ()=>{})
.delete("/a", ()=>{})
or
router.url("/a").get(fn).post(fn).get("/:id", fn).del(fn)
equals:
router.get("/a", ()=>{})
.post("/a", ()=>{})
.get("/a/:id", ()=>{})
.delete("/a/:id", ()=>{})
you can use this as middleware
router.use((req, resp, next)=>{console.log(1);next()})
router.get("/a",(req, resp, next)=>{console.log(2);next()})
router.use((req, resp, next)=>{console.log(3);next()})
// result log: 1, 2, 3
router.use((req, resp, next)=>{console.log(1);next()})
router.use((req, resp, next)=>{console.log(3);next()})
router.get("/a",(req, resp, next)=>{console.log(2);next()})
// result log: 1, 3, 2
FAQs
it snowed today, I write a simple route
We found that snow-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.