diff --git a/api/openapi.yaml b/api/openapi.yaml index 07fb3b5..f4965d4 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -2,7 +2,7 @@ openapi: "3.0.3" info: title: TaskForge API description: A minimal Express task management API. - version: "1.0.0" + version: "2.0.0" paths: /api/tasks: get: @@ -71,25 +71,6 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" - delete: - summary: Delete Task - description: Delete a task by ID. - operationId: deleteTask - parameters: - - name: taskId - in: path - required: true - schema: - type: integer - responses: - "204": - description: Task deleted - "404": - description: Task not found - content: - application/json: - schema: - $ref: "#/components/schemas/Error" /api/health: get: summary: Health Check @@ -124,22 +105,29 @@ components: created_at: type: string format: date-time - assignee: + assigned_to: type: string nullable: true TaskCreate: type: object required: - title + - priority properties: title: type: string description: type: string nullable: true - assignee: + assigned_to: type: string nullable: true + priority: + type: string + enum: + - low + - medium + - high HealthResponse: type: object required: @@ -149,7 +137,7 @@ components: status: type: string uptime: - type: integer + type: string Error: type: object properties: diff --git a/app.js b/app.js index 8046aa7..08021fb 100644 --- a/app.js +++ b/app.js @@ -17,19 +17,23 @@ app.get("/api/tasks", (req, res) => { res.json(result); }); -// Create task +// Create task — now requires priority, uses assigned_to instead of assignee app.post("/api/tasks", (req, res) => { - const { title, description, assignee } = req.body; + const { title, description, assigned_to, priority } = req.body; if (!title) { return res.status(422).json({ detail: "title is required" }); } + if (!priority) { + return res.status(422).json({ detail: "priority is required" }); + } const task = { id: nextId++, title, description: description || null, status: "pending", created_at: new Date().toISOString(), - assignee: assignee || null, + assigned_to: assigned_to || null, + priority, }; tasks.push(task); res.status(201).json(task); @@ -44,21 +48,13 @@ app.get("/api/tasks/:id", (req, res) => { res.json(task); }); -// Delete task by ID -app.delete("/api/tasks/:id", (req, res) => { - const index = tasks.findIndex((t) => t.id === parseInt(req.params.id)); - if (index === -1) { - return res.status(404).json({ detail: "Task not found" }); - } - tasks.splice(index, 1); - res.status(204).send(); -}); +// DELETE endpoint removed -// Health check +// Health check — uptime changed from number to string app.get("/api/health", (req, res) => { res.json({ status: "healthy", - uptime: Math.floor(process.uptime()), + uptime: `${Math.floor(process.uptime())} seconds`, }); });