Skip to content
This repository has been archived by the owner. It is now read-only.
Super simple mock API endpoints for static JSON data
JavaScript Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci Modernize configuration infrastructure; get rid of secrets.js Feb 15, 2017
config Don't bundle client-side Raven if Sentry isn't used Mar 11, 2017
src Properly enable CORS Mar 5, 2018
test Properly enable CORS Mar 5, 2018
.babelrc Drop rewire plugin from production bundle Mar 13, 2017
.eslintignore Add client-side Sentry config secrets and test Feb 6, 2017
.eslintrc Initial commit: server-side logic Feb 5, 2017
.gitignore Modernize configuration infrastructure; get rid of secrets.js Feb 15, 2017
.stylelintrc
.travis.yml Modernize configuration infrastructure; get rid of secrets.js Feb 15, 2017
LICENSE Initial commit: server-side logic Feb 5, 2017
README.md Modernize configuration infrastructure; get rid of secrets.js Feb 15, 2017
index.js Modernize configuration infrastructure; get rid of secrets.js Feb 15, 2017
package.json Properly enable CORS Mar 5, 2018

README.md

endpoint

Build Status Coverage Status

Super simple mock API endpoints for static JSON data

$ curl -X PUT http://endpoint.example.com/api/endpoint/add -d '{"name": "my-endpoint", "data": {"hello": "world"}}'
{
  "success": true,
  "name": "my-endpoint",
  "data": {
    "hello": "world"
  },
  "statusCode": 200,
  "delay": 0
}

$ curl http://endpoint.example.com/endpoint/my-endpoint
{
  "hello": "world"
}

Screencast

Screencast

Overview

endpoint is a self-hosted microservice for quickly creating configurable mock HTTP endpoints that return static JSON data. It's intended to be a super simple, zero-configuration, zero-server-overhead way of associating some JSON with a URL in order to test webhooks or client libraries during development.

endpoint is especially useful for testing client-side logic when a live production server is either not yet ready or unavailable in a development environment.

Endpoint JSON data is persistently stored on-disk and cached in-memory, completely eliminating the need for any database configuration.

Features

  • Associate arbitrary JSON data with any endpoint name
  • Specify a custom HTTP response status code
  • Specify a custom response delay (e.g. for testing behavior under slow network conditions)

Installation

Locally

$ npm install
$ npm run build
$ npm run start
# A local instance is now available at http://localhost:16540

Production (Apache reverse proxy, with pm2):

First, in the shell:

$ cd /path/to/endpoint
$ npm install
$ NODE_ENV=production npm run build
$ pm2 start index.js

A minimal Apache config:

<VirtualHost *:80>
    Alias "/static" "/path/to/endpoint/src/client/static"

    ProxyPass "/static" !

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:16540/
    ProxyPassReverse / http://127.0.0.1:16540/
</VirtualHost>

If your production infrastructure makes use of Sentry, you may optionally run the build and start scripts with the environment variables SERVER_SENTRY_DSN and CLIENT_SENTRY_DSN defined either in the shell or saved in .env.

You can’t perform that action at this time.