
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@kitabisa/smockr
Advanced tools
Supple mock server with random fake data using Faker.js
Setup smockr with npm
$ npm install -g @kitabisa/smockr
Setup smockr with bun
$ bun add -g @kitabisa/smockr
Setup smockr with docker
$ docker pull kitabisa/smockr
Running mock with default params
$ smockr
Running mock with custom params
$ smockr \
--port 3000 \
--secret "mysecret" \
--allowOrigin "*.kitabisa.com,*.kitajaga.id" \
--allowMethods "GET,POST,PATCH" \
--allowHeaders "Content-Type,Authorization"
When you define secret
as a parameter and is not empty string, the client request must be include X-Smockr-Secret
header with the same value
See a list of all available options
$ smockr --help
See a installed version
$ smockr --version
Running mock with default params
$ docker run -p 8080:8080 --rm \
kitabisa/smockr
Running mock with custom params
$ docker run -p 3000:3000 --rm -e \
PORT=3000 \
SECRET_KEY="mysecret" \
ALLOWED_ORIGIN="*.kitabisa.com,*.kitajaga.id" \
ALLOWED_METHODS="GET,POST,PATCH" \
ALLOWED_HEADERS="Content-Type,Authorization" \
kitabisa/smockr
Specify a search body param to retrieve a response with that body.
GET http://localhost:8080/?mock[response][body]={"ping":"pong"}
HTTP/1.1 200 OK
content-type: application/json
content-length: 18
{
"ping": "pong"
}
Specify a search body param with random fake data using faker.js.
GET http://localhost:8080/?mock[response][body]={"id":{{number.int({"min":100000,"max":900000})}},"name":"{{person.fullName}}","avatar":"{{image.avatar}}"}
HTTP/1.1 200 OK
content-type: application/json
content-length: 107
{
"id": 429178,
"name": "Allen Brown",
"avatar": "https://avatars.githubusercontent.com/u/97165289"
}
Specify a search status param get back that code status. The status must be inside the range 200 to 599.
GET http://localhost:8080/?mock[response][status]=301
HTTP/1.1 301 Moved Permanently
content-type: application/json
content-length: 0
Specify a search headers param as json string to get them back.
GET http://localhost:8080/?mock[response][headers]={"x-hello":"world"}
HTTP/1.1 200 OK
content-type: application/json
content-length: 0
x-hello: world
Specify a search delay param in milliseconds in order to delay the response.
GET http://localhost:8080/?mock[response][delay]=3000
HTTP/1.1 200 OK
content-type: application/json
content-length: 0
Specify a search schema validation in json schema (stringify) to set request body validation.
POST http://localhost:8080/?mock[request][body][schema]={"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer","minimum":17}},"required":["name"]}
{
"age": 20
}
HTTP/1.1 400 Bad Request
content-type: application/json
content-length: 84
{
"code": 400,
"message": "Requires property name",
"type": "SchemaValidationException"
}
Predefined health check route.
GET http://localhost:8080/health-check
HTTP/1.1 200 OK
content-type: application/json
content-length: 24
{
"health_check": "up"
}
Want to contribute? Awesome! You can find information about contributing to this project in the CONTRIBUTING.md
FAQs
Supple mock server with random fake data using Faker.js
The npm package @kitabisa/smockr receives a total of 0 weekly downloads. As such, @kitabisa/smockr popularity was classified as not popular.
We found that @kitabisa/smockr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.