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.
simple-json-replay-server
Advanced tools
A simple json replay server which can be used for standalone frontend web application (angular especially) when development. Simply put the url & parameters & response json data, then hit the url in browser or from your web application, whenever it match
Pefect companion with angular 1/2 development, and unit mock testing.
Have you spent a lot of time trying to find a simple straight-forward file based json replay server which will just matching url and query parameters and return response you expect?
You probably will be disappointed, because not all but at least majority of them are fancy shinning restful style severs which either return dynamic json in memory or manipulate some text based db files. And obviously, they will all require you to send standard restful style requests and then response with some dynamic results which you might have to think hard to set it up.
Isn't it overkill? if we just need a mock server for development and unit testing. Or, if you have legacy backend API design, which are not strictly following restful specifications.
Install to your package.json
npm install simple-json-replay-server --save-dev
Create app_mock folder under your application root
go to your application root folder, where it has package.json & your node_modules folder.
mkdir app_mock
Create mock data config files
Create a json file, eg. example.json inside of app_mock folder, you can create any layer of sub folders to hold this file.
Once start replay server, you can hit http://localhost:8008/test to see the result.
Please note: you are able to config a different port number if it conflicts.
Example:
{
"request" : {
"url": "test",
"method" : "get"
},
"response" : {
"status" : 200,
"data" : {
"message" : "you made it!"
}
}
}
Start the replay server
node node_modules/simple-json-replay-server/src/main.js
As we all know, nowadays, most of frontend projects have been completely seperated from backend projects.
When we develop frontend application, we often tend to mock the data either directly in the code or hard-coded in backend service before implemented, which will requires some code changes during integration phase. And more often it is not easy to setup mock data which can cover many business scenarios.
With this simple json replay server approach, your code is always the same code which you will use in production, and in local development environment, you can route all your backend restful service calls to this replay server and thus you can run and play with your frontend application without ANY dependency on your backend server.
I will take two most popular frontend build tools/solutions for example:
Webpack based solution is gaining more popularity, and both angular 2 official and one of most popular tools - angular-cli are all using webpack as their build tool.
FAQs
A simple json replay server which can be used for standalone frontend web application (angular especially) when development. Simply put the url & parameters & response json data, then hit the url in browser or from your web application, whenever it match
The npm package simple-json-replay-server receives a total of 68 weekly downloads. As such, simple-json-replay-server popularity was classified as not popular.
We found that simple-json-replay-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.