Example of a Docker Node application that is an express server connecting to a database and exposing some endpoints for a Todo application.
All responses are JSON based.
{
"success": false,
"data": "The error message will be here"
}
Response:
{
"success": true,
"data": {
"rows": [
{
"id": "UNIQUE-ID",
"description": "Description of the TODO",
"completed": 0 || 1,
"date": "UNIX LONG FORMAT DATE"
}
],
"rowCount": 0
}
}
Example Response:
{
"success": true,
"data": {
"rows": [
{
"id": "9DF788A0-1A29-11ED-8739-679AC04E7140",
"description": "some text",
"completed": false,
"date": 1660300156458
}
],
"rowCount": 1
}
}
The same than the previous but the result will be only one.
Response:
{
"success": true,
"data": {
"rows": [
{
// See previous example
}
],
"rowCount": 1
}
}
Add one new item. Body to send.
Body:
{
"description": "YOUR DESCRIPTION HERE",
"completed": 0 || 1
}
Response:
{
"success": true
}
Removes a todo from the database by id.
Response:
{
"success": true
}
Update a todo on the database by id. It always set the date as the time the petittion is done.
Body:
{
"description": "YOUR NEW DESCRIPTION HERE",
"completed": 0 || 1,
}
Response:
{
"success": true
}
- Create a docker network
docker network create analyted_network
- Run the analyted-database-todo docker image (see their documentation)
- Run a
docker network inspect analyted_network
and check the IP wheresqltodo
is running - Change on the
src/index.js
the ip of the server
For login into Github repository:
npm run docker:login
For building:
npm run docker:build
. To build the latest versionsnpm run docker:build <version>
. To build the a concrete version
For running:
npm run docker:run
. To run the latest versionsnpm run docker:run <version>
. To run the a concrete version
For pulling (You need to be logged in and with rights to do it):
npm run docker:pull
. To run the latest versionsnpm run docker:pull <version>
. To run the a concrete version