New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/mysurii/mock-server

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mysurii/mock-server

  • v0.0.0-20241002133547-ce27a9515887
  • Source
  • Go
  • Socket score

Version published
Created
Source

Mock Server Generator

A lightweight mock server generator in Go that allows developers to easily create mock APIs based on JSON configurations, facilitating rapid frontend development and testing without backend dependencies.

Features

  • Dynamic API Endpoints: Define API endpoints in JSON configuration files.
  • Flexible Response Handling: Return mock responses based on the defined structure in the configuration.
  • File-Based Configuration: Load payloads from JSON files for endpoints.
  • CLI Integration: Simple command-line interface to initialize and run the mock server.

Installation

To install the mock server generator, clone the repository and build the project:

git clone https://github.com/Mysurii/mock-server.git
cd mock-server-generator
go build ./cmd/cli/main.go

Usage

To run the mock server, use the following command:

./main.exe --config path/to/config.json

Or run the following command to create needed config file & example payload files

./main.exe --example

Config format

The configuration file should be in JSON format. Here is an example:

{
  "port": 8080,
  "endpoints": [
    {
      "method": "POST",
      "status": 200,
      "path": "/login",
      "jsonPath": "./mock/auth/login.json"
    },
    {
      "method": "GET",
      "status": 200,
      "path": "/users",
      "jsonPath": "./mock/users/users.json"
    },
    {
      "method": "POST",
      "status": 201,
      "path": "/users"
    },
    {
      "method": "GET",
      "status": 200,
      "path": "/users/{id}",
      "jsonPath": "./mock/users/user.json"
    }
  ]
}

Contribution

Contributions are welcome! Feel free to submit a pull request or create an issue for any enhancements or bug fixes.

FAQs

Package last updated on 02 Oct 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