Installations
npm install koa-route
Developer
koajs
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
20.10.0
NPM Version
10.2.3
Statistics
446 Stars
89 Commits
46 Forks
11 Watching
9 Branches
28 Contributors
Updated on 14 Aug 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
27,534,126
Last day
-38.4%
16,680
Compared to previous day
Last week
-20.3%
106,580
Compared to previous week
Last month
7.6%
540,502
Compared to previous month
Last year
-27.4%
4,982,220
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
koa-route
Uber simple route middleware for koa.
1const _ = require('koa-route'); 2app.use(_.get('/pets', pets.list)); 3app.use(_.get('/pets/:name', pets.show));
If you need a full-featured solution check out koa-router, a Koa clone of express-resource.
Installation
1$ npm install koa-route
Example
Contrived resource-oriented example:
1const _ = require('koa-route'); 2const Koa = require('koa'); 3const app = new Koa(); 4 5const db = { 6 tobi: { name: 'tobi', species: 'ferret' }, 7 loki: { name: 'loki', species: 'ferret' }, 8 jane: { name: 'jane', species: 'ferret' } 9}; 10 11const pets = { 12 list: (ctx) => { 13 const names = Object.keys(db); 14 ctx.body = 'pets: ' + names.join(', '); 15 }, 16 17 show: (ctx, name) => { 18 const pet = db[name]; 19 if (!pet) return ctx.throw('cannot find that pet', 404); 20 ctx.body = pet.name + ' is a ' + pet.species; 21 } 22}; 23 24app.use(_.get('/pets', pets.list)); 25app.use(_.get('/pets/:name', pets.show)); 26 27app.listen(3000, (err) => { 28 if (err) console.error(err.stack); 29 else console.log('listening on port 3000'); 30});
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/koajs/.github/SECURITY.md:1
- Info: Found linked content: github.com/koajs/.github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/koajs/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/koajs/.github/SECURITY.md:1
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/koajs/route/node.js.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/koajs/route/node.js.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
Found 5/27 approved changesets -- score normalized to 1
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
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Score
4.2
/10
Last Scanned on 2024-11-18
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