This TO-DO app allows users to maintain a list of tasks to do. The app allows users to create, update and delete
TO-DOs, with more functions listed below.
requests.log
: In charge of logging each incoming request of any type to the servertodos.log
: In charge of logging information regarding the todo management
- You can download and import the following Postman files into Postman to see an example of some requests and responses from the server:
Local-Server-Test Run.postman_collection.json
- for a local instance of the server that is runningGCP-Deployed-Server-Test-Run.postman_collection.json
- to use the Google Cloud Platform deployed instance
- You can also use the
Dockerfile
to build and run a docker container with the todo-serverNotes and instructions on how to use the docker container are inside the Dockerfile
- Through GCP - enter the URL:
https://todo-server-2aj6ey6ugq-zf.a.run.app
, with the endpoints described below
Id:
a unique ID assigned for each TO-DO, Starting at 1Title:
short title describing the essence of this TO-DOContent:
the actual content/description describing what this TO-DO stands forDue date:
a timestamp (in millisecs) denoting the target time for this TO-DO to be fulfilledStatus:
the status of the TO-DO as follows,PENDING
when it is created and before the due dateLATE
when it is not performed yet, and we are past the due dateDONE
when the TO-DO item processing is over
Java
- programming languageSpring-Boot
- web frameworkLogback
- logging frameworkSLF4J
- Simple Logging Facade for JavaDocker
- docker containers for ease of use
endpoints will return a result in the Json format:
{
result: <result of operation> (Template, depends on the context)
errorMessage: <message in case of error> (String)
}
The server is set to listen on port 9583
.
This can be changed in the application.properties
file, under the server.port
property.
This is a sanity endpoint used to check that the server is up and running.
Endpoint:
/todo/health
Method:
GET
- The response code will be 200
- The result will be the string "OK".
Creates a new TO-DO item in the system.
Endpoint:
/todo
Method:
POST
Body:
json object-
{
title: <TO-DO title> (String)
content: <TO-DO description> (String)
dueDate: <timestamp in millisecs> (long number)
}
The TO-DO is created with the status PENDING.
When a new TO-DO is created, it is assigned by the server to the next id in turn.
- Is there already a TO-DO with this title (TO-DOs' titles are unique)
- Is the dueDate in the future.
- The response code will be 200
- The result will hold the newly assigned TO-DO number
- The response will end with 409 (conflict)
- The errorMessage will be set according to the error:
TO-DO already exists:
"Error: TODO with the title [] already exists in the system"due date is in the past:
“Error: Can’t create new TODO that its due date is in the past”
Returns the total number of TO-DOs in the app, according to the given filter.
Endpoint:
/todo/size
Method:
GET
Query Parameter:
status, possible values- ALL
, PENDING
, LATE
, DONE
.
- The response code will be 200
- The result will hold the number of TO-DOs that have the given status
If that status is not precisely the above four options (case sensitive) the result will be 400 (bad request).
Returns the content of the todos according to the given status.
Endpoint:
/todo/content
Method:
GET
Query Parameter:
status, possible values- ALL
, PENDING
, LATE
, DONE
Query Parameter:
sortBy, optional, possible values- ID
, DUE_DATE
, TITLE
(default value: ID
).
- The response will be a json array
- The array will hold json objects that describe a single TO-DO
- The array will be sorted according to the sortBy parameter, in an acending order
- If no TO-DOs are available the result is an empty array
Each Json object in the array holds:
{
id: Integer
title: String
content: String
status: String
dueDate: long (Timestamp in millisecs)
}
- The response code will be 200
- The result will hold the json array as described above
In case status or sortBy are not precisely as the options mentioned above, case sensitive, the result is 400 (bad request).
Updates a TO-DO's status property.
Endpoint:
/todo
Method:
PUT
Query Parameter:
id, The TO-DO ID
Query Parameter:
status, The status to update. possible values- PENDING
, LATE
, DONE
- The response code will be 200
- Its status will be updated
- The result is the name of the OLD state that this TO-DO was at (any option of PENDING, LATE, or DONE, case sensitive)
- The response code will be 404 (not found)
- The errorMessage will be: "Error: no such TODO with id "
- The result and response code will be 400 (bad request)
Deletes a TO-DO object.
Endpoint:
/todo
Method:
DELETE
Query Parameter:
id, The TO-DO ID
Once deleted, its deleted id remains empty, so that the next TO-DO that will be created will not take this id
- The response will end with 200
- The result will hold the number of TO-DOs left in the app
- The response will end with 404 (not found)
- The errorMessage will be: "Error: no such TODO with id "
Use the docker image from Docker-Hub to simply use the server and test its capabilities without worrying about setting it up.
- Docker-Hub link: https://hub.docker.com/r/idansm/todo-server
You can pull the docker image through Docker-Desktop by using the tag idansm/todo-server:1.0
,
or by using the following command in the terminal:
docker pull idansm/todo-server:1.0
You need to install docker on your machine in order to run it properly
docker build -t todo-server:1.0 . --platform linux/amd64
Flags used:
-t
- used for the tag (name) of the docker container, where the number (1.0) refers to the version of the server (not required, but helps with version control)--platform linux/amd64
- states the target platform of the docker container to be Linux or Windows, remove the flag to run it on MacOS
docker run --name todo-server -d -p 3769:9285 todo-server:1.0
Flags used:
-p
- makes the external exposed port of the server to be 3769, and the internal port of the server (the port that the server actualy listens to, inside the docker container) to be 9285-d
- runs the docker container in the backgroud, enables use of the terminal after running the docker container (can be removed to see the logs of the server that were writen to the screen)--name
- the name of the docker container created from the run commandtodo-server:1.0
is the image tag of the image created by the build command