The intented use is you spin this up a mock service as a container using docker-compose
, and the entire service is configuration driven mounted as a volume at /app/conf/
of the container, the entry point is config.json
version: '3'
services:
mock-svc:
image: davidcheung/ghetto-mock:latest
volumes:
# Mount your folder with routes/payloads to the image
- ./<folder>:/app/conf/
routes executed are determined req.url.includes(route)
by top to bottom of the config using Array.find
[
{
"method": "POST",
"route": "/ping",
/* location of payload, loaded via `require`, so it will work with js/json */
"payloadPath": "post.json"
},
{
"method": "GET",
"route": "/ping",
/* location of payload, loaded via `require`, so it will work with js/json */
"payloadPath": "get"
},
{
"route": "/",
"payload": { // payload takes precedence over payloadPath
"success": true
},
"log": "${new Date()} - ${req.url}"
}
]
module.exports = (req) => ({ success: true, data: req.url })
{
"success": "true",
"data": "data from Post.json"
}
# For development
version: '3'
services:
mock-random-service:
# container_name: mock-svc
ports:
- 8080:8080
build:
context: .
dockerfile: ./Dockerfile.dev
volumes:
- ./src:/app/src/
- ./example/config:/app/conf/