Installations
npm install snb-mock-middleware
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.16.0
NPM Version
6.14.11
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
cherislive
Download Statistics
Total Downloads
3,327
Last Day
4
Last Week
32
Last Month
59
Last Year
317
GitHub Statistics
11 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
1.40 MB
Minified
517.39 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.2.21
Package Id
snb-mock-middleware@1.2.21
Unpacked Size
320.92 kB
Size
185.92 kB
File Count
13
NPM Version
6.14.11
Node Version
14.16.0
Total Downloads
Cumulative downloads
Total Downloads
3,327
Last day
33.3%
4
Compared to previous day
Last week
966.7%
32
Compared to previous week
Last month
1,866.7%
59
Compared to previous month
Last year
-35.6%
317
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
25
Dev Dependencies
1
snb-mock-middleware
Mock middleware for mocking restful APIs.
Install
yarn add snb-mock-middleware -D
or
npm install --save-dev snb-mock-middleware
Usage
Used in the Node environment
1const express = require('express'); 2const path = require('path'); 3const createtMockMiddleware = require('./dist/index'); 4var app = express(); 5app.use( 6 createtMockMiddleware({ 7 cwd: path.join(__dirname, '/'), 8 }), 9); 10 11const server = app.listen(3000, () => { 12 const host = server.address().address; 13 const port = server.address().port; 14 console.log('Example app listening at http://%s:%s', host, port); 15});
Used in a front-end development environment
1module.exports = { 2 devServer: { 3 before: (app) => { 4 app.use( 5 createMock({ 6 cwd: path.join(__dirname, '/'), 7 }), 8 ); 9 }, 10 } 11}
Mock files
For example in file /mock/api.js, you can have content
1const mockjs = require('mockjs'); 2 3const getActivities = [ 4 { 5 id: 'trend-1', 6 updatedAt: new Date(), 7 user: { 8 name: '曲丽丽', 9 }, 10 group: { 11 name: 'é«˜é€¼æ ¼è®¾è®¡å¤©å›¢', 12 link: 'http://github.com/', 13 }, 14 project: { 15 name: 'å…月è¿ä»£', 16 link: 'http://github.com/', 17 }, 18 template: '在 @{group} 新建项目 @{project}', 19 }, 20]; 21 22exports.default = { 23 'GET /api/activities': getActivities, 24 'POST /api/forms': (req, res) => { 25 res.send({ message: 'Ok' }); 26 }, 27 'GET /api/tags': mockjs.mock({ 28 'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }], 29 }), 30}; 31
FAQ
Move to: issues
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/11 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 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
license file not detected
Details
- Warn: project does not have a license file
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 'main'
Score
2.6
/10
Last Scanned on 2025-01-27
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