This TODO API allows you to manage your todo items. You can create, read, update, and delete todos. The API is built using AWS Lambda, API Gateway, and DynamoDB. It is designed to be deployed using the Serverless Framework.
- Getting Started
- Prerequisites
- Installation
- Configuration
- Deploying the Application
- Running Tests
- API Endpoints
- License
To get started with the TODO API, follow the instructions below to set up and deploy the application.
- Node.js (v14.x or later)
- npm or yarn
- AWS account
- Serverless Framework
-
Clone the repository:
git clone https://github.com/your-username/todo-api.git cd todo-api
-
Install dependencies:
npm install
-
Environment Variables: Create a
.env
file in the root directory and add the following environment variables:AWS_REGION=your-aws-region TODOS_TABLE=your-dynamodb-table-name
-
Serverless Configuration: Update the
serverless.yml
file with your AWS region and DynamoDB table name.
To deploy the application to AWS, use the Serverless Framework:
serverless deploy
To run the tests for the TODO API, use the following command:
npm test
Here are the available endpoints for the TODO API:
- URL:
/todos
- Method:
POST
- Description: Create a new todo item.
- Request Body:
{ "title": "Comprar leche", "metadata": { "prioridad": "alta" } }
- Response:
{ "id": "1234", "title": "Comprar leche", "completed": false, "metadata": { "prioridad": "alta" } }
- URL:
/todos
- Method:
GET
- Description: Retrieve a list of all todo items.
- Response:
[ { "id": "1234", "title": "Comprar leche", "completed": false, "metadata": { "prioridad": "alta" } } ]
- URL:
/todos/{id}
- Method:
PUT
- Description: Update an existing todo item.
- Request Body:
{ "title": "Comprar leche y pan", "completed": true, "metadata": { "prioridad": "alta" } }
- Response:
{ "id": "1234", "title": "Comprar leche y pan", "completed": true, "metadata": { "prioridad": "alta" } }
- URL:
/todos/{id}
- Method:
DELETE
- Description: Delete a completed todo item.
- Response:
{ "message": "Todo deleted successfully" }
- URL:
/todos/{id}
- Method:
DELETE
- Description: Return an error if the todo item is not completed.
- Response:
{ "error": "Todo must be completed before deletion" }
This README provides a comprehensive guide to setting up, deploying, and using the TODO API. If you encounter any issues or have questions open an issue on the repository.