Skip to content

About

Fake your requests to an fake server!

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

Fake Server

GitHub release (latest by date) GitHub tag (latest by date) License

The purpose of FakeServer is to respond to a request regardless of the route or method (POST, GET...) called, being mainly used as a server for tests during the development of an application.

Contents

Features

  • HTTP verb agnostic
  • Sleep request by passing queryString fs-sleep with time in ms
    • Eg: http://localhost:8088/my-super-test?fs-sleep=5000
  • Status code agnostic by passing queryString fs-status
    • Eg: http://localhost:8088/my-super-test?fs-status=404
  • Response contents:
    • body
    • errors
    • headers
    • method
    • path
    • query
    • time

Example

Inside a Docker, localhost is called: http://host.docker.internal:8088

Request:

curl --request POST \
  --url http://localhost:8088/cart/62582df20e2cd6a770aa9e5b \
  --header 'Content-Type: application/json' \
  --data '{
    "cart_id": 123,
    "items": [
      { "name": "Smartphone", "price": 155.99, "quantity": 1 },
      { "name": "Mouse", "price": 23.50, "quantity": 2 }
    ]}'

Response:

{
  "body": {
    "cart_id": 123,
    "items": [
      {
        "name": "Smartphone",
        "price": 155.99,
        "quantity": 1
      },
      {
        "name": "Mouse",
        "price": 23.5,
        "quantity": 2
      }
    ]
  },
  "errors": {},
  "headers": {
    "Accept": [ "*/*" ],
    "Content-Length": [ "170" ],
    "Content-Type": [ "application/json" ],
    "User-Agent": [ "insomnia/2022.2.1" ]
  },
  "method": "POST",
  "path": "/cart/62582df20e2cd6a770aa9e5b",
  "query": {},
  "time": "2022-04-14T19:13:21-03:00"
}

Install

You can access the latest releases page and download the compressed file according to your operating system.

Build

You must have Golang installed to be able to make the build

$ git clone https://github.com/budnieswski/fake-server.git
$ cd fake-server
$ go build .
$ ./fake-server # Run application

Download

Linux

$ wget -q -O - https://github.com/budnieswski/fake-server/releases/latest/download/fake-server_Linux_x86_64.tar.gz \
| tar -xz

$ ./fake-server # Run application

MacOS

M1 architecture (arm64)
$ wget -q -O - https://github.com/budnieswski/fake-server/releases/latest/download/fake-server_macOS_arm64.tar.gz \
| tar -xz

$ ./fake-server # Run application
Intel/AMD architecture (x86_64)
$ wget -q -O - https://github.com/budnieswski/fake-server/releases/latest/download/fake-server_macOS_x86_64.tar.gz \
| tar -xz

$ ./fake-server # Run application

Windows

You can download the latest version here

Goals

  • Create flags
    • Help
    • Version
    • Run in background
    • Custom port
  • Create sleep request
  • Create custom status code
  • Add workflow to build app and create a release
    • Linux
    • MacOS
    • Windows

About

Fake your requests to an fake server!

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages