cburnicki / mock-service

Very simple nodeJS server that can mock a http service by sending json/error/static responses.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mock Service

Mock service may mock any http service. It runs on the port given in MOCK_PORT (default is 8000). It will automatically log datetime, method, url and headers of each incoming request.

npm run serve or npm run build & npm run serve starts the server.

Successful Responses

JSON

  • A GET request to /json will return the query params as a json body. I.e. GET /json?foo=bar will return a body {"foo": "bar"}.
  • A POST request to /json will just return the request body back to you.

Static files

Put your static files in a directory given in the STATIC_DIR environment variable (default: ./static). Any request to /static/* will serve your files.

Delays and timeouts

  • A query param ?delay={t} causes the server to delay it's response for {t}ms.

Errors and other status responses

  • Any request to /status/{code} will send back a response with http status code {code}.

About

Very simple nodeJS server that can mock a http service by sending json/error/static responses.


Languages

Language:TypeScript 95.6%Language:HTML 4.4%