Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
mock-js-server
Advanced tools
A mock server that allow to generate responses by JSONs or JSs files
The first step is to configure config/routes.json
, where we will map our API endpoint routes to JSON/JS files.
{
"^$": "../config/info.json",
".*user.*": "user/default.js"
}
There're multiple options to return a response via this server:
This wil return JSON response at it's defined in the JSON file.
{
"status": "OK"
}
/*globals req, params, query, mock*/
mock = {
'id': Math.floor(Math.random()*1000)
}
if (query) {
if (query.name && query.surname)
mock.fullname = `${query.name} ${query.surname}`;
}
You must use the @mock
key to add contenType or statusCodel ike this:
{
"@mock": {
"status": 404,
"contentType": "text/html",
"content": "<html><head><title>404</title></head><body>You hit a 404</body></html>"
}
}
Also you can add a download action to the mock:
{
"@mock": {
"status": 200,
"@download": "./LICENSE"
}
}
Just run npm start
to run it simple or configure as tu want with these options:
Option | Key | Default | Description |
---|---|---|---|
Config file | -c | config.json | Name of configuration file |
Config Folder | --config-folder | ./config/ | Path of configuration's folder |
Routes File | --routes-file | routes.json | Name of the routes file |
Mock Folder | --mocks-folder | ./mocks/ | Path of the mock folder |
Port | -p | None | Listening port |
Delay | -d | None | Delay in ms |
FAQs
Mock server for API
The npm package mock-js-server receives a total of 21 weekly downloads. As such, mock-js-server popularity was classified as not popular.
We found that mock-js-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.