Skip to content
This repository was archived by the owner on Apr 24, 2026. It is now read-only.
Open
Show file tree
Hide file tree
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
34 changes: 11 additions & 23 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -149,7 +137,7 @@ components:
status:
type: string
uptime:
type: integer
type: string
Error:
type: object
properties:
Expand Down
24 changes: 10 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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`,
});
});

Expand Down
Loading