Skip to main content

Endpoint

GET
/tasks/{id}
Retrieves a specific task by its ID

Request

Path Parameters

id
number
required
The unique identifier of the task to retrieve

Example Request

curl -X GET http://localhost:9999/tasks/1

Response

task
object
The requested task object

Status Codes

200
OK
Successfully retrieved the task
404
Not Found
Task with the specified ID does not exist
422
Unprocessable Entity
Invalid ID parameter (must be a valid number)

Example Responses

{
  "id": 1,
  "name": "Complete project documentation",
  "done": false,
  "createdAt": "2024-03-15T10:30:00.000Z",
  "updatedAt": "2024-03-15T10:30:00.000Z"
}

Implementation Details

This endpoint is defined in src/routes/tasks/tasks.routes.ts:45-66 and implemented in src/routes/tasks/tasks.handlers.ts:24-42. The endpoint validates the ID parameter using IdParamsSchema from the stoker library, queries the database for a matching task, and returns a 404 error if no task is found with the specified ID.

Build docs developers (and LLMs) love