Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Have you ever had to delay your UI development to wait for a backend team to implement the APIs you need?
Mockwave lets you create mock API endpoints while seamlessly proxying all other requests to the real API, combining the flexibility of mocking with the reliability of a live backend.
While you wait for the API team to implement the new APIs you need for your UI development, you can create temporary endpoints that return mock or test data.
Mockwave is still in an early stage. I hope you find it useful but please feel free to open feature requests!
Install Mockwave in your project:
npm install mockwave
Mockwave uses Fastify under the hood for mock API routes. Routes are defined using Fastify handler functions. This gives you the full power of the Fastify framework. Your mock APIs can return static data or contain logic.
Mock APIs are defined in a JavaScript file. The convention is for the file name to end with .mock.js
, but this is just a convention and is not required.
The file should have a default export which is a function. The function takes one argument, server
, which is the underlying Fastify instance. From here, you can define your own mock endpoints and their data or behavior.
See the Fastify documentation for more details on adding routes.
Here is an example mock file:
export default function myMock(app) {
app.get('/api/test', (request, reply) => {
reply
.code(200)
.send({ hello: 'world' });
});
}
You can split up your mocks into multiple .mock.js
files. Just specify them as a space-separated list on the command line when you run Mockwave.
Once you have your mocks defined in a mock file, you can start Mockwave. You'll need the file name of the mock as well as the URL you want to proxy other requests to.
The structure of the command is:
npx mockwave -t <proxy target> <mock file name>
Assuming you want to proxy to https://httpbin.org
and your mock file is called myMock.mock.js
, the command is as follows:
npx mockwave -t https://httpbin.org myMock.mock.js
By default, Mockwave listens on port 8000. If you need a different port, you can specify the -p
option and enter a different port number.
Now, when you send a request to http://localhost:8000, if it matches one of your mock routes, your mock will handle it. Otherwise, the request will be proxied to https://httpbin.org.
1.0.0 (2024-10-27)
FAQs
API proxy with mocking support
The npm package mockwave receives a total of 1 weekly downloads. As such, mockwave popularity was classified as not popular.
We found that mockwave demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.