- Description: Retrieve all tasks.
- Response:
200 OK: Returns a list of tasks.
- Description: Retrieve a specific task by ID.
- URL Parameters:
id(integer): ID of the task.
- Responses:
200 OK: Returns task details.404 Not Found: Task does not exist.
- Description: Create a new task.
- Request Body:
{ "title": "Task title", "description": "Task description", "status": "pending", "due_date": "2025-04-27", } - Responses:
201 Created: Task created successfully.400 Bad Request: Invalid input data.
- Description: Update the status of a task.
- URL Parameters:
id(integer): ID of the task.
- Request Body:
{ "status": "completed" } - Responses:
200 OK: Task status updated.404 Not Found: Task does not exist.
- Description: Delete a task by ID.
- URL Parameters:
id(integer): ID of the task.
- Responses:
204 No Content: Task successfully deleted.404 Not Found: Task does not exist.
This project is intended to run locally and is not production ready.
One line installation
npm install express@4.21.2 pg@8.13.3 dotenv@16.4.7 cors@2.8.5
Install postgreSQL and log in as the superuser. Create a 'caseworker' role and grant it database creation permission.
- psql -U postgres
- CREATE ROLE caseworker WITH LOGIN PASSWORD 'password';
- ALTER USER caseworker CREATEDB;
As I'm sure you're aware - you should change that sample username, and that password is strongly discouraged.
Exit PostgreSQL from previous session, log in as 'caseworker' user, create the database and grant db permissions.
- \q
- psql -d postgres -U caseworker
- CREATE DATABASE tasks;
- \c tasks
- GRANT USAGE, CREATE ON SCHEMA public TO caseworker;
Run the following SQL commands from the task database
- Mandatory: create the tasks table
CREATE TABLE tasks (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
status VARCHAR(50) NOT NULL,
due_date TIMESTAMP
);
- Optional: add dummy data
INSERT INTO tasks (title, description, status, due_date)
VALUES
('demo task', 'sample task for database testing', 'complete', '2025-04-28'),
('example task', 'you need example tasks', 'complete', '2025-04-28');
Create a .env file and include the following:
DB_USER=caseworker
DB_HOST=localhost
DB_DATABASE=tasks
DB_PASSWORD=password
DB_PORT=5432
node index.js
For use with client at https://github.com/hmct-application-projects/task-tracker-frontend
- by default runs at http://127.0.0.1:3000/