Socket
Socket
Sign inDemoInstall

smockr

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smockr

CLI tools for serve supple mock server with random fake data using Faker.js


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

smockr

CLI tools for serve supple mock server with random fake data using Faker.js

Features

  • Using Bun
  • Using Express.js for API routes
  • Written in Typescript
  • Random fake data using Faker.js
  • Schema validation using JSON Schema
  • Flexible on-demand response (can modify body, status, headers, and delayed response)
  • No data storage needed

Getting Started

Setup smockr

$ npm install --global smockr

Quick Start

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"

See a list of all available options

$ smockr --help

See a installed version

$ smockr --version

Usage

Body

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: 15

{"ping":"pong"}

Status

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

Headers

Specify a search header param as json string to get them back.

GET http://localhost:8080/?mock\[response\]\[headers\]={"x-hello":"world"}


HTTP/1.1 200 OK
x-hello: world
content-length: 0

Delay

Specify a search delay param in milliseconds in order to delay the response.

GET http://localhost:8080/?mock\[response\]\[delay\]=3000

Schema Validations

Specify a search schema validation in json schema (stringify) to set request body validations.

GET http://localhost:8080/?mock\[request\]\[body\]\[schema\]=${{ stringify json schema }}

Keywords

FAQs

Package last updated on 09 Apr 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc