Installations
npm install egg-router-decorator
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=8.9.0
Node Version
8.11.1
NPM Version
6.3.0
Score
71.4
Supply Chain
98.8
Quality
75.2
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
SuuQi
Download Statistics
Total Downloads
8,833
Last Day
1
Last Week
80
Last Month
295
Last Year
3,375
GitHub Statistics
8 Stars
12 Commits
3 Forks
2 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
2.1.0
Package Id
egg-router-decorator@2.1.0
Unpacked Size
18.22 kB
Size
5.62 kB
File Count
7
NPM Version
6.3.0
Node Version
8.11.1
Total Downloads
Cumulative downloads
Total Downloads
8,833
Last day
-93.8%
1
Compared to previous day
Last week
-30.4%
80
Compared to previous week
Last month
2.1%
295
Compared to previous month
Last year
-1.3%
3,375
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
egg-router-decorator
装饰者模式写egg-router(Routers for eggjs by decorator pattern)。
Usage
For Install
1npm install --save egg-router-decorator
Setup
In router.ts
or route.js
1// router.ts or route.js 2import { Application } from 'egg'; 3import { initRouter } from 'egg-router-decorator'; 4 5export default (app: Application) => { 6 initRouter(app); 7}
Prefix Url Globally
1// router.ts or `router.js` 2initRouter(app, { prefix: '/api' }) 3 4// controller.ts or `controller.js` 5export default class index extends Controller { 6 @routerDecorator.get('/user') //===>>/api/user 7 async get() { 8 this.ctx.body = 'hello, egg-router-decorator.' 9 } 10} 11
Prefix Url For Controller
1// controller.ts or `controller.js` 2import routerDecorator from 'egg-router-decorator'; 3 4@routerDecorator.prefix('/home') 5export default class home extends Controller { 6 @routerDecorator.get('/test') //===>>/home/test 7 async get() { 8 this.ctx.body = 'hello, egg-router-decorator.' 9 } 10} 11
Router Middleware
Router middleware will run before the target function.
Example
1import { Controller } from 'egg'; 2import routerDecorator from 'egg-router-decorator'; 3 4// @routerDecorator.prefix('/example') 5@routerDecorator.prefix('/example', (ctx, next) => { 6 console.log(ctx.request.URL); 7 console.log('ExampleController的prefix中的中间件1'); 8 next(); 9}, async (ctx, next) => { 10 await next(); 11 console.log(ctx.request.URL); 12 console.log('ExampleController的prefix中的中间件2'); 13}) 14export default class ExampleController extends Controller { 15 16 @routerDecorator.get('/index') // ===>>/example/index get 17 @routerDecorator.post('/index2') // ===>>/example/index2 post 18 public async test1 () { 19 const { ctx } = this; 20 ctx.body = 'hello, egg-router-decorator.' 21 } 22 23 @routerDecorator.put('/parms/:id') // ===>>/parms/:id put 24 public async test2 () { 25 const { ctx } = this; 26 ctx.body = 'hello, egg-router-decorator.' 27 } 28 29 @routerDecorator.del('/parms/:id/:pwd', isLogin, hasDelAuth) // ===>>/parms/:id/:pwd del 30 public async test3 () { 31 const { ctx } = this; 32 ctx.body = 'hello, egg-router-decorator.' 33 } 34} 35 36// isLogin middleware 37const isLogin = async (ctx, next) => { 38 if (ctx.params['id']) { 39 await next(); 40 } else { 41 ctx.status = 401; 42 } 43} 44 45// hasDelAuth middleware 46const hasDelAuth = async (ctx, next) => { 47 if (ctx.params['pwd'] === 'admin') { 48 await next(); 49 // ctx.body = 'xxx' 50 } else { 51 ctx.status = 403; 52 } 53} 54
The MIT License (MIT)
Copyright (c) hzsuqin 15957136119@163.com
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENCE:0
- Info: FSF or OSI recognized license: MIT License: LICENCE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
71 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-9j49-mfvp-vmhm
- Warn: Project is vulnerable to: GHSA-wm7h-9275-46v2
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-gjm5-83cw-p3p2
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9
- Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4
- Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g
- Warn: Project is vulnerable to: GHSA-56x4-j7p9-fcf9
- Warn: Project is vulnerable to: GHSA-v78c-4p63-2j6c
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-4c7m-wxvm-r7gc / GHSA-pch5-whg9-qr2r
- Warn: Project is vulnerable to: GHSA-x77j-w7wf-fjmw
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-29xr-v42j-r956
- Warn: Project is vulnerable to: GHSA-3329-pjwv-fjpg
- Warn: Project is vulnerable to: GHSA-p6j9-7xhc-rhwp
- Warn: Project is vulnerable to: GHSA-89gv-h8wf-cg8r
- Warn: Project is vulnerable to: GHSA-gcv8-gh4r-25x6
- Warn: Project is vulnerable to: GHSA-gmv4-r438-p67f
- Warn: Project is vulnerable to: GHSA-8h2f-7jc4-7m3m
- Warn: Project is vulnerable to: GHSA-3vjf-82ff-p4r3
- Warn: Project is vulnerable to: GHSA-g694-m8vq-gv9h
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.7
/10
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 MoreOther packages similar to egg-router-decorator
egg-decorator-router
Define egg.js router and middleware use decorator
egg-router-util
egg router decorator util -> simple way to define api router
egg-swagger-decorator
using decorator to make router definitions and automatically generate swagger doc for egg.js
egg-route-decorator
Define egg.js router and middleware use decorator