-
Notifications
You must be signed in to change notification settings - Fork 0
REST API
NexTask exposes a small REST API served by Fastify, running inside the Electron main process. The renderer consumes it through Axios; you can also call it directly during development.
-
Base URL:
http://localhost:3000(configurable viaVITE_BASE_URL) -
Interactive docs (Swagger UI):
http://localhost:3000/docs -
Content type:
application/json -
CORS: enabled for
GET, POST, PUT, DELETE, PATCH
The server (src/main/server/index.ts) registers CORS, Swagger, the Swagger UI, and the task and stage route plugins, then listens on port 3000.
Because every route declares a Fastify JSON schema, the OpenAPI spec is generated automatically. Open http://localhost:3000/docs while the app is running to browse and try every endpoint. The spec is titled nexTask API, version 1.0.2.
| Method | Path | Description |
|---|---|---|
GET |
/tasks |
List all tasks (optionally filter by isHistorized) |
GET |
/tasks/:id |
Get a single task |
POST |
/tasks |
Create a task |
PATCH |
/tasks/:id |
Update a task (partial) |
PUT |
/tasks/:id |
Archive (historize) a task |
DELETE |
/tasks/:id |
Delete a task |
PATCH |
/tasks/batch |
Update many tasks in one transaction |
| Method | Path | Description |
|---|---|---|
GET |
/stages |
List all stages with their tasks |
GET |
/stages/:id |
Get a single stage |
POST |
/stages |
Create a stage |
PATCH |
/stages/:id |
Update a stage (name / position) |
DELETE |
/stages/:id |
Delete a stage |
PATCH |
/stages/batch |
Update many stages in one transaction |
Returns all tasks, ordered by stageId then position.
Query parameters
| Name | Type | Description |
|---|---|---|
isHistorized |
boolean |
Optional. If provided, filters to archived (true) or active (false) tasks. Omit to return all. |
curl "http://localhost:3000/tasks?isHistorized=false"Returns a single task, or 404 if not found.
curl http://localhost:3000/tasks/1Creates a task.
Body (required: stageId, position, title, version, description)
{
"stageId": 1,
"position": 0,
"title": "Write the wiki",
"version": "1.5.0",
"description": "Document the whole project"
}Returns the created task (200).
Partially updates a task. Any subset of these fields may be sent:
{
"title": "New title",
"version": "1.5.0",
"description": "…",
"position": 2,
"stageId": 3,
"isHistorized": false,
"historizationDate": null
}Returns the updated task, or 404 if it does not exist.
Marks a task as historized (archived): sets isHistorized = true, stamps historizationDate, and clears stageId. This is what the board's "trash" button triggers.
curl -X PUT http://localhost:3000/tasks/1Response:
{ "message": "Tâche 1 marquée comme historisée" }Permanently deletes a task. Returns { "message": "Tâche supprimée" } or 404.
Updates many tasks atomically (a single Prisma $transaction). Used by drag-and-drop to persist new positions/columns in one call.
Body: an array of objects, each requiring id:
[
{ "id": 1, "position": 0, "stageId": 2 },
{ "id": 2, "position": 1, "stageId": 2 }
]Returns the array of updated tasks. Responds 400 if the array is empty, 500 on failure.
ℹ️ The static route
/tasks/batchis intentionally distinct from the parameterized/tasks/:id; Fastify's router resolves the static path first.
Returns all stages, each including its tasks, ordered by id then position. This is the endpoint the board uses on load — the renderer derives the full task list from it in one round-trip.
curl http://localhost:3000/stagesReturns a single stage, or 404.
Creates a stage.
Body (required: name, position)
{ "name": "Backlog", "position": 5 }Updates a stage's name and/or position. Returns the updated stage, or 404.
Deletes a stage. At the database level, its tasks' stageId is set to NULL (ON DELETE SET NULL). Returns { "message": "Stage supprimée" } or 404.
In the UI, deleting a stage additionally archives its active tasks first (handled in the Stage store, not the API). See Frontend.
Updates many stages atomically (used when reordering columns via drag-and-drop).
Body: array of objects, each requiring id:
[
{ "id": 1, "position": 1 },
{ "id": 2, "position": 0 }
]Returns the updated stages. Responds 400 if empty, 500 on failure.
Errors are returned as a JSON object with an error message and the corresponding HTTP status:
{ "error": "Tâche non trouvée" }| Status | Meaning |
|---|---|
200 |
Success |
400 |
Bad request (e.g. empty batch array) |
404 |
Resource not found |
500 |
Server-side failure |
The Axios wrapper (src/renderer/utils/api.helper.ts) rethrows non-2xx responses as Error objects containing the status, status text and body — so store actions can catch and log them.
NexTask — a modern cross-platform desktop todo app · Electron · Vue 3 · Prisma · TailwindCSS Repository · Licensed under Apache-2.0
Getting Started
Understanding the App
Deep Dives
Workflow