项目作者: szkrd

项目描述 :
Transparent, aggressive api cache/proxy.
高级语言: JavaScript
项目地址: git://github.com/szkrd/pied-piper.git
创建时间: 2016-06-24T17:39:21Z
项目社区:https://github.com/szkrd/pied-piper

开源协议:MIT License

下载


pied-piper

Transparent, aggressive API cache/proxy.

Pied piper is a tool to alleviate the pain of working with slow APIs. It can:

  • store API responses in a database and retrieve them,
    instead of trying to fetch it from the API itself.
  • dump server responses so you can edit or review them
  • respond with fake data for different requests

It uses no etags and tries to be as transparent as possible,
but it is a high level tool, meant to work with JSON requests/responses.

The name comes from the folk tale Rat-Catcher of Hamelin,
this tool has nothing to do with tv series or startups.

usage

Instead of calling your http://foo.bar.dev:8080/api/,
you have to change the api url in your frontend code to be something
like http://localhost:3100/myproject/proxy (myproject can be
a name of your session, project or anything, this will be the collection
id in the database and it will group requests together).

runtime configuration

  • recording:true - toggle recording of responses into db
  • strict:false - match and record in/from db with request body (otherwise record/match with request method
    and request uri only); not really recommended with arbitrary user data, but it’s up to you.
  • active:true - if inactive, all the requests will be forwarded to the remote api
  • dump:true - save responses into dump directory
  • sleep:0 - sleep in sec (to sleep on a certain response only, use fakes’ generator response)
  • disabledProjects:[] - array of strings, same as active, but on a per project basis

See default values,
api interface

env vars example

  1. {
  2. "env": {
  3. "LOG_LEVEL": "silly",
  4. "NODE_ENV": "development",
  5. "TARGET": "http://dev.foo.bar.local/api",
  6. "MONGODB_URI": "mongodb://localhost:27017/piedpiper",
  7. "HTTPS_KEY": "local.key",
  8. "HTTPS_CERT": "local.crt"
  9. }
  10. }

API documentation

https support

So far the server can run on https (supply both the cert and the key through env vars),
but https target endpoints are not supported. I will add support, if I need it.

TODO

  • rezip gzipped responses