A super simple persistent API using MongoDB
The docker-compose.yml
file has been setup to run the whole stack without anything required on the host other than docker. Just run:
docker-compose up
Having npm & nodejs installed on the host can streamline development, as you can then bring up the app on the host using node src/index.js
, or install nodemon (npm install -g nodemon
), and run nodemon src/index.js
to restart the node process when any file changes are detected. If you want to run the node app locally (as outlined above), then only bring up the other services using docker:
docker-compose up mongo mongo-express
Once this has been done, you should have the following docker containers running:
- mongo (The MongoDB database server)
- mongo-express (web interface to view and interact with the MongoDB database, accessible at http://localhost:8081)
- time-logger (The dockerised nodejs application that runs the web api)
When making changes and running the application in docker, you may need to rebuild the docker image to reflect code changes:
docker-compose up --build
Once all the services are running, you can start making requests against the API. It'll be easiest to use VS Code and install the Rest Client plugin, and then use the requests.rest
file to initiate the example API requests.