Gathering detailed insights and metrics for mock-restful-service
Gathering detailed insights and metrics for mock-restful-service
Gathering detailed insights and metrics for mock-restful-service
Gathering detailed insights and metrics for mock-restful-service
npm install mock-restful-service
Typescript
Module System
Node Version
NPM Version
68.5
Supply Chain
91.4
Quality
74.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
857
Last Day
2
Last Week
4
Last Month
11
Last Year
64
8 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
mock-restful-service@1.0.1
Size
2.92 kB
NPM Version
5.5.1
Node Version
8.3.0
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
0%
4
Compared to previous week
Last month
450%
11
Compared to previous month
Last year
-26.4%
64
Compared to previous year
2
Simple to use express middleware for creating mock REST services. Define routes (sets of requests and responses) as json objects and configure the express middleware to use the routes.
Create custom responses for each route (request path and method)
Create custom responses based on the requests body (headers coming soon!) as well as creating a default response
URL (request path) pattern matching with Regex
Create required fields for a request body and specify response status/body if fields are not met
Specify '404 Not Found' response (status/body) OR pass through if route is not founc
Below is the most basic use of mock-restful-service
1const express = require('express'); 2const mockRestfulSerice = require('mock-restful-service'); 3 4const app = express(); 5 6const routes = [ 7 { 8 path: '/sample', 9 method: 'get', 10 defaultResponse: { 11 status: 200, 12 body: { message: 'Hello World!' } 13 } 14 }, 15 ] 16 17app.use(mockRestfulSerice(routes)); 18 19app.listen(8002, () => { 20 console.log('server now listening on 8002. Open http://localhost:8002'); 21}); 22
key | Type(s) | Required? | Description |
---|---|---|---|
path | string, regex | true | Partial URL of request |
regex | boolean | false | True if using regex for path param |
method | string | true | HTTP method (get, post, put, delete, etc.) |
requiredFields | Array | false | An array of the required fields (not applicable to get method) |
requiredFieldsResponse | Object | false | The status and the body if any of the required fields are missing |
defaultResponse | Object | true | The status and body if none of the responseMappings are matched (see below) |
responseMappings | Array | false | An array of request/response pairs. If the request is received, then the response will be returned |
1{ 2 path: '/user', 3 regex: false, 4 method: 'post', 5 requiredFields: ['username'], 6 requiredFieldsResponse: { 7 status: 400, 8 body: { error: 'Required field validation'} 9 }, 10 defaultResponse: { 11 status: 201, 12 body: { message: 'created'} 13 }, 14 responseMappings: [ 15 { 16 request: { 17 body: { username: 'jdoe' } 18 }, 19 response: { 20 status: 400, 21 body: { error: 'this username already exists' } 22 } 23 } 24 ] 25 },
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/7 approved changesets -- 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
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
45 existing vulnerabilities detected
Details
Score
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