
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Remok is a simple record and replay capable mock server.
Remok is available as the remok
package on npm.
npm install --save-dev remok
const remok = require('remok');
const server = remok({
server: {
port: 3000,
},
mocks: {
path: './mocks',
},
proxy: {
target: 'https://some.api.tld',
},
});
server.start();
$ remok --config ./remok.config.js
// remok.config.js
module.exports = {
proxy: {
target: 'https://some.api.tld',
},
}
You can test your setup by sending a request to the server:
curl http://localhost:3000/some/endpoint
Remok will always try to load a /path/to/mock/<METHOD>.@override.json
file first,
afterwards it searches for a /path/to/mock/<METHOD>.<REQUEST_HASH>.json
file.
You can use the remok create-mock ./foo/GET
CLI command in order to create a manual mock.
Activating the watch-mode mocks.watch: true
will load new mocks without having to restart Remok.
The following fields are required in a mock file:
{
"time": "2018-01-01T00:00:00.000Z",
"request": {
"_hash": "requesthashvalue",
"method": "GET",
"path": "/foo/bar",
"headers": {
"key": "value"
},
"query": null,
"body": null
},
"response": {
"_hash": "responsehashvalue",
"_time": null,
"status": {
"code": 201,
"message": "custom status message"
},
"headers": {
"key": "value"
},
"body": "I'm the response body!"
}
}
🚧
Creates the Remok application.
Property | Type | Default | Description |
---|---|---|---|
verbose | boolean | true | Makes output more or less verbose |
server.port | number | 3000 | Server port |
server.host | string | localhost | Server host |
mocks.record | mixed | true | Whether to record mocks. Setting this option to overwrite will overwrite existing mocks. |
mocks.path | string | ./remok | Path used for storing recorded mocks |
mocks.history 🚧 | boolean | false | Use the history mode |
mocks.watch | boolean | false | Reloads all mocks on every request. Useful for developing with manual mocks. |
mocks.reqHash | function | Callback; receives a Request object, should return a request hash | |
mocks.resHash | function | Callback; receives a HttpResponse object, Should return a response hash | |
proxy.target | string | http://localhost | The proxy target |
proxy.timeout | number | 5000 | Proxy request timeout in milliseconds |
async
Starts the Remok server.
async
Stops the Remok server.
Mounts the specified middleware for the specified path.
Property | Type | Description |
---|---|---|
path | string | Route path. |
callback | mixed | Callback; can be: A middleware function. A class with a invoke() method. |
Mounts the specified proxy middleware for the specified path.
Property | Type | Description |
---|---|---|
path | string | Route path. |
callback | mixed | Callback; can be: A middleware function. A class with a invoke() method. |
In order to detect new requests, Remok calculates hashes based on the request and response data.
Please make sure to exclude request and response headers that change on every request.
In this example, body and headers are not used for calculating the hash:
// Calculates a SHA256 hash. You can use any other hash function.
const hash = require('remok/dist/hash');
remok({
mocks: {
requestHash: (Request) => hash(Request.method + Request.url),
},
})
🚧
You can setup scenarios by running Remok with a scenario-specific mock path:
// Scenario A
remok({
mocks: {
path: './mocks/scenario-a',
}
});
// Scenario B
remok({
mocks: {
path: './mocks/scenario-b',
}
});
Remok is licensed under the MIT License - see the LICENSE
file for details.
FAQs
A simple record and replay capable mock server.
The npm package remok receives a total of 4 weekly downloads. As such, remok popularity was classified as not popular.
We found that remok 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.