This repository is responsible for implementing a docker web-api-mocker image solution for frontend development purposes.
Behind the scenes, It combines connect-api-mocker and localtunnel packages in a single docker image solution.
You can find the local image here: https://hub.docker.com/r/andrebnassis/web-api-mocker
- run the following command:
docker run --env SUBDOMAIN="" --env URL_PATH="/" -d -p 3000:3000 --name web-api-mocker andrebnassis/web-api-mocker-
Then you'll be able to see an API response sample by accessing:
http://localhost:3000/ -
You can check the WorldWide link generated by executing the following command on bash:
docker exec -it web-api-mocker yarn pm2:logsThe image uses connect api mocker package behind the scenes, so, you can follow its Directory Structure documentation to create your own web api mocker folder structure
The repo has a sample/ folder with a docker-compose file and sample file structure requests. You can just copy the entire folder to your project and adjust to your needs.
docker-compose up -d
docker-compose down -v
You can find the complete docker run command below:
docker run -v $(pwd)/data:/app/data:ro --env SUBDOMAIN="" --env URL_PATH="/" -d -p 3000:3000 --name web-api-mocker andrebnassis/web-api-mockerIt runs over port 3000.
$(pwd)/data:/app/data:ro:
$(pwd)/datais the folder's path related to yourconnect api mockermock api directory.
SUBDOMAIN="":
- (OPTIONAL) It is the subdomain of the url. It generates the url
https://<SUBDOMAIN>.loca.lt/.
If not passed, it will NOT generate any WorldWide link.
If passed as empty string or if passed an already existant subdomain, it generates a random subdomain. Then, you can check it by entering inside the container and running
yarn pm2:logscommand on your container.
docker exec -it <container_id> yarn pm2:logsURL_PATH:
- (OPTIONAL) It is a path related to the url. For example:
"/api".
PS: If not passed, it is filled with
"/"
If you just follow the docker commands on README, here it is some tips that will fits you:
docker exec -it web-api-mocker sh
docker logs web-api-mocker
docker rm -f web-api-mocker
docker image rm andrebnassis/web-api-mocker
docker build . -t "andrebnassis/web-api-mocker:latest"