Module: todoController

Handles todo-related operations such as creating, updating, and deleting todos.
Source:

Methods

(async, static) createTodo(req, res) → {Promise.<void>}

The function `createTodo` handles creating a new to-do item by validating input, inserting the data into the database, and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
body Object The body of the request, containing to-do item data.
Properties
Name Type Description
title string The title of the to-do item.
description string The description of the to-do item.
headers Object The headers of the request, containing the JWT token for authentication.
Properties
Name Type Description
authorization string The JWT token for authentication.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if validation fails or if there is an issue with database interaction.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>

(async, static) deleteTodo(req, res) → {Promise.<void>}

The function `deleteTodo` handles deleting an existing to-do item by deleting the data from the database and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
headers Object The headers of the request, containing the JWT token for authentication.
Properties
Name Type Description
authorization string The JWT token for authentication.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if there is an issue with database interaction.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>

(async, static) getTodos(req, res) → {Promise.<void>}

The function `getTodos` handles retrieving a list of to-do items from the database and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
query Object The query parameters of the request, containing pagination details.
Properties
Name Type Description
page number The page number for pagination.
limit number The limit of items per page for pagination.
headers Object The headers of the request, containing the JWT token for authentication.
Properties
Name Type Description
authorization string The JWT token for authentication.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if there is an issue with database interaction.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>

(async, static) updateTodo(req, res) → {Promise.<void>}

The function `updateTodo` handles updating an existing to-do item by validating input, updating the data in the database, and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
body Object The body of the request, containing to-do item data.
Properties
Name Type Description
title string The title of the to-do item.
description string The description of the to-do item.
headers Object The headers of the request, containing the JWT token for authentication.
Properties
Name Type Description
authorization string The JWT token for authentication.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if validation fails or if there is an issue with database interaction.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>