This project is a personal learning exercise in building a REST API using modern technologies and best practices. The aim of this project is to gain hands-on experience in designing, implementing, and testing a production-grade API. The API will provide basic functionality for managing tasks and lists, as well as user authentication. 🚀📚
In addition to the main functionality, the API will also handle static files such as images. This will provide a complete experience in building a REST API that includes serving static files. 🖼️
To run this project, you will need the following tools:
Docker is a tool used to automate the deployment of applications within containers. To install Docker, follow these steps:
- Go to the official website and download the package for your operating system.
- Follow the installation instructions provided in the package.
To run this project, follow these steps:
- Clone the repository to your local machine.
- Navigate to the project's root directory.
- Create a
.env
file with the necessary environment variables (see the Environment Variables section above for details). - Run
docker compose build
to build the Docker images. - Run
docker compose up
to start the containers.
Once the containers are running, you can access the API via http://localhost:8000
. 🚀🌐
The following environment variables must be declared to run the API:
PORT
: The port number on which the server will listen.SRV_HOST
: The hostname for the server.SRV_SECRET_KEY
: A secret key used for encrypting session data.SRV_ALLOWED_ORIGINS
: The allowed host origins to use this server.DB_USER
: The username for the database connection.DB_PASSWORD
: The password for the database connection.DB_NAME
: The name of the database.DB_HOST
: The host of the database.DB_PORT
: The port of the database.
Here is an example .env
file:
PORT=8000
SRV_HOST=localhost
SRV_SECRET_KEY=mysecretkey
SRV_ALLOWED_ORIGINS=*
DB_USER=todo
DB_PASSWORD=mysecretpassword
DB_NAME=tasks_db
DB_HOST=localhost
DB_PORT=5432
The API provides a range of useful endpoints for developers to leverage. In addition to the currently available endpoints, there are plans to expand the API with new endpoints in upcoming releases. Some of the current endpoints include those for user authentication, data retrieval, and data modification. As the API continues to evolve, it will be important to stay up to date on the latest developments to ensure that your application is making the most of the available endpoints. 🚀📚
This endpoint returns all the tasks belonging to an account in the database.
Returns a specific task with the given {id}.
Creates a new task with the given parameters:
- task_name
- task_description
- task_due_date
- task_status
Updates an existing task with the given {id}. The following parameters can be updated:
- title
- description
- list_id
Deletes a specific task with the given {id}.
Returns all the lists in the database
.
Returns a specific list with the given {id}.
Creates a new list with the given parameters:
- title
- description
- background_picture_url
- created_by
Updates an existing list with the given {id}. The following parameters can be updated:
- title
- description
- background_picture_url
Deletes a specific list with the given {id}.
Registers a new user with the given parameters:
- name
- last_name
- nickname
- password
Authenticates a user with the given credentials:
- nickname
- password
This project implements error handling at every layer of the architecture, including the database layer, database implementation, server layer, and server implementation. This ensures that errors are caught and handled appropriately, improving the reliability and stability of the API. Specific error messages are returned to the client to help with debugging and troubleshooting.
This API is very simple, but it has all the necessary functionality to perform CRUD operations on lists, tasks, and basic authentication services. It provides a great foundation for building more advanced features and expanding the capabilities of your application. Keep exploring and learning!