0.1.0 • Published 5 years ago

evalserver v0.1.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Evalserver

Eval server is a REST mocking tool that allows templating and changing of states.

Starting

You can start the server as follows

const { startServer } = require("./index")

startServer(9000, "./mock/", "mock", "status");
startServer
portThe port to host the mocking server on
mockFolderThe folder to look in for mocks
mockPrefixA prefix url to the mock, i.e localhost:port/prefix will point to root
statusPrefixA prefix url to get to the status pages

Structure

Each endpoint should be located in a separate folder under you mock folder.

The folder should contain a get.json with a template to be returned.

The template can contain {{variables}} that will be matched to a state found in state.js which should do a "normal" module.exports of its state.

Example

mock/asd/get.json:

{
    "param": "hello {{data}}!"
}

mock/asd/state.js:

module.exports = {
    data: "world"
}

HTTP GET http://localhost:9000/mock/asd/

{
    "param": "hello world!"
}

HTTP GET http://localhost:9000/status/asd/

{
  "hits": 1
}