Gathering detailed insights and metrics for egg-router-plus
Gathering detailed insights and metrics for egg-router-plus
Gathering detailed insights and metrics for egg-router-plus
Gathering detailed insights and metrics for egg-router-plus
npm install egg-router-plus
Typescript
Module System
Min. Node Version
Node Version
NPM Version
68.5
Supply Chain
96.4
Quality
81.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
336,119
Last Day
215
Last Week
1,573
Last Month
7,041
Last Year
86,068
140 Stars
22 Commits
9 Forks
19 Watching
1 Branches
27 Contributors
Latest Version
2.0.0
Package Id
egg-router-plus@2.0.0
Size
5.00 kB
NPM Version
6.14.8
Node Version
10.16.0
Publised On
12 Jul 2021
Cumulative downloads
Total Downloads
Last day
-13.7%
215
Compared to previous day
Last week
-5.3%
1,573
Compared to previous week
Last month
12%
7,041
Compared to previous month
Last year
27%
86,068
Compared to previous year
3
The missing router features for eggjs
1$ npm i egg-router-plus --save
Then mount plugin:
1// {app_root}/config/plugin.js 2exports.routerPlus = { 3 enable: true, 4 package: 'egg-router-plus', 5};
app/router/**/*.js
this plugin will auto load router define at app/router/**/*.js
.
Notice: all sub routers will be loaded before app/router.js
, please ensure all the sub router definitions are not conflict(better to use app.router.namespace
to create different namespaces for each sub router file).
1app.router.namespace(prefix, ...middlewares);
prefix
- {String}, the prefix string of sub routermiddlewares
- {...Function}, optional group middlewaresSupport same as Router:
router.verb('path-match', app.controller.action);
router.verb('path-match', middleware1, ..., middlewareN, app.controller.action);
router.verb('router-name', 'path-match', app.controller.action);
router.verb('router-name', 'path-match', middleware1, ..., middlewareN, app.controller.action);
prefix
and path
are not allow to be regex
, and prefix
can't be '/'.
1// {app_root}/app/router.js 2module.exports = app => { 3 const subRouter = app.router.namespace('/sub'); 4 // curl localhost:7001/sub/test 5 subRouter.get('/test', app.controller.sub.test); 6 subRouter.get('sub_upload', '/upload', app.controller.sub.upload); 7 8 // const subRouter = app.router.namespace('/sub/:id'); 9 // const subRouter = app.router.namespace('/sub', app.middleware.jsonp()); 10 11 // output: /sub/upload 12 console.log(app.url('sub_upload')); 13};
Every different prefix will bind to different router instance, and all the namespaces will sort by trie tree to ensure best match.
1module.exports = app => { 2 const apiRouter = app.router.namespace('/api'); 3 const apiWebRouter = app.router.namespace('/api/web'); 4 const apiWebAdminRouter = app.router.namespace('/api/web/admin'); 5 apiRouter.get('/:a/:b/:c', controller.api.one); 6 apiWebRouter.get('/:a/:b', controller.api.two); 7 apiWebAdminRouter.get('/:a', controller.api.three); 8 // /api/web/admin/hello => controller.api.three 9 // /api/web/foo/hello => controller.api.two 10 // /api/foo/bar/hello => controller.api.one 11};
redirect
is not support, use app.router.redirect()
or redirect to a named router.1const subRouter = app.router.namespace('/sub'); 2 3// will redirect `/sub/go` to `/anyway`, not `/sub/anyway` 4subRouter.redirect('/go', '/anyway'); 5 6// just use router 7router.redirect('/sub/go', '/sub/anyway'); 8 9// or redirect to a named router 10subRouter.get('name_router', '/anyway', app.controller.sub.anyway); 11// will redirect `/sub/go_name` to `/sub/anyway` which is named `name_router` 12subRouter.redirect('/sub/go_name', 'name_router');
Please open an issue here.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 10/22 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More