Sign inSign up

draynow/mock-services

By draynow

•Updated over 7 years ago

Image
0

10K+

draynow/mock-services repository overview

⁠Mock Services

This project is for creating mock services that are not ideal (or not available) via Docker images.

⁠Usage

In the binci.yml for a project, add the following to services:

services:
  - mock-services:
      from: 571506782996.dkr.ecr.us-east-1.amazonaws.com/draynow/mock-services
      expose:
        - 9000:9000

⁠Development

⁠Mocks Directory

The /mocks⁠ directory contains files which are mapped to endpoints matching their name, i.e. ./mock/<mock-file> would create endpoints at http://<mock-service>/<mock-file>/....

In order to make these available, mock files should export an array of one or more endpoints in the following object format:

// FILENAME: /mocks/foo.js
[
  {
    path: '/some/path', // Support :param path string format
    method: 'post', // HTTP method to bind to
    fn: (req, res) => {
      // Logic...
      res.status(/*xxx*/).send(/*xxx*/)
    }
  }
]

When the above export is processed by index.js⁠ when the service starts it will create the following:

app.post('/foo/some/path', <fn>)
⁠Modelling Data

In order to replicate mocks correctly, obey is included in the dependencies to allow for creating data models which can be validated when a request is sent to the mock endpoint.

Tag summary

Content type

Image

Digest

Size

101.1 MB

Last updated

over 7 years ago

docker pull draynow/mock-services