Gathering detailed insights and metrics for koa-mock-restful
Gathering detailed insights and metrics for koa-mock-restful
npm install koa-mock-restful
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
3,443
Last Day
1
Last Week
26
Last Month
48
Last Year
809
1 Stars
8 Commits
2 Watching
1 Branches
1 Contributors
Latest Version
1.0.4
Package Id
koa-mock-restful@1.0.4
Unpacked Size
14.38 kB
Size
4.37 kB
File Count
16
NPM Version
6.13.4
Node Version
10.18.1
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
766.7%
26
Compared to previous week
Last month
-20%
48
Compared to previous month
Last year
91.3%
809
Compared to previous year
koa-mock-restful is a koa middleware that creates mocks for REST APIs. It will be helpful when you try to test your application without the actual REST API server.
Features:
🔥 Built in support for hot Mocker file replacement.
🚀 Quickly and easily configure the API via JSON.
1npm install koa-mock-restful --save-dev
koa-mock-restful dev support mock, configured in mocker.js
.
1const mockMap = { 2 'GET /api/user': { 3 username: 'admin', 4 sex: 5, 5 }, 6 'GET /repos/hello': (ctx, next) => { 7 ctx.body = { 8 text: 'this is from mock server', 9 }; 10 }, 11 'GET /api/userinfo/:id': (ctx, next) => { 12 ctx.body = { 13 id: ctx.params.id, 14 username: 'kenny', 15 }; 16 }, 17 'GET /api/user/list/:id/:type': (ctx, next) => { 18 ctx.body = { 19 id: ctx.params.id, 20 type: ctx.params.type, 21 }; 22 }, 23 24 'POST /api/login/account': (ctx, next) => { 25 const {password, username} = ctx.request.body; 26 if (password === '888888' && username === 'admin') { 27 ctx.body = { 28 status: 'ok', 29 code: 0, 30 token: 'sdfsdfsdfdsf', 31 data: { 32 id: 1, 33 username: 'kenny', 34 sex: 6, 35 }, 36 }; 37 } else { 38 ctx.body = { 39 status: 'error', 40 code: 403, 41 }; 42 } 43 }, 44 'DELETE /api/user/:id': (ctx, next) => { 45 ctx.body = {status: 'ok', message: '删除成功!', id: ctx.params.id}; 46 }, 47} 48module.exports = mockMap;
1apiMocker({entry:'./mocker.js',debug:true})
1const path = require('path'); 2const koa = require('koa'); 3+ const apiMocker = require('koa-mock-restful'); 4 5const app = koa(); 6 7+ app.use(apiMocker({entry:'./mocker/index.js',debug:true}); 8app.listen(8080);
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
Found 0/8 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-20
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