Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions api/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,53 @@ module.exports = Router()
})
)

/**
* @swagger
* /tasks/{taskId}:
* get:
* summary: Get a single task that is requested via Id
* parameters:
* - name: taskId
* in: path
* description: The unique ID of a task.
* schema:
* type: string
* format: objectId
* responses:
* 200:
* description: A task
* content:
* application/json:
* schema:
* $ref: "#/components/schemas/Task"
* 400:
* $ref: "#/components/responses/BadRequest"
* 404:
* $ref: "#/components/responses/NotFound"
*/
.get("/:taskId", (request, response) =>
runWithDB(async db => {
validateRequest(request, {
paramSchemaProps: {
taskId: { type: "string", format: "objectId" }
}
})

const tasksCollection = db.collection("tasks")

const { taskId } = request.params
const searchResult = await tasksCollection.findOne(
{ _id: new ObjectId(taskId) }
)

if (!searchResult) {
throw new HTTPError(404, `No task with id "${taskId}"`)
} else {
response.status(200).send(searchResult)
}
})
)

/**
* @swagger
* /tasks/{taskId}:
Expand Down