RESTful API for task management built with TypeScript, Express, and TypeORM.
User entity represents system users with authentication and authorization capabilities.
Fields:
id- Unique identifier (auto-generated)email- User's email (unique, required)password- Hashed password (required)username- User's username (unique, optional)name- User's full name (optional)role- User role:STANDARDorADMINISTRATOR(default:STANDARD)language- Preferred language (default:en-US)created_at- Account creation timestampupdated_at- Last update timestamp
Relationships:
- One user can have many States (one-to-many)
- One user can have many TaskTypes (one-to-many)
- One user can have many Tasks (one-to-many)
State entity represents task statuses (e.g., "To Do", "In Progress", "Done"). Each user can create their own custom states.
Fields:
id- Unique identifier (auto-generated)name- State name (max 100 characters, required)userId- Reference to the owner usercreated_at- Creation timestampupdated_at- Last update timestamp
Relationships:
- Many-to-one with User (each state belongs to one user)
TaskType entity represents task categories or types (e.g., "Bug", "Feature", "Documentation"). Each user can create their own custom task types.
Fields:
id- Unique identifier (auto-generated)name- Task type name (max 100 characters, required)userId- Reference to the owner usercreated_at- Creation timestampupdated_at- Last update timestamp
Relationships:
- Many-to-one with User (each task type belongs to one user)
Task entity represents individual tasks with all their details.
Fields:
id- Unique identifier (auto-generated)title- Task title (max 200 characters, required)description- Task description (optional)priority- Task priority:LOW,MEDIUM, orHIGH(required)userId- Reference to the owner user (auto-assigned, cannot be changed)stateId- Reference to the task's state (required, must belong to user)taskTypeId- Reference to the task's type (required, must belong to user)dueDate- Task due date (required)created_at- Creation timestampupdated_at- Last update timestamp
Relationships:
- Many-to-one with User (each task belongs to one user)
- Many-to-one with State (each task has one state)
- Many-to-one with TaskType (each task has one type)
Validation Rules:
- When creating a task, all fields except
descriptionare required stateIdandtaskTypeIdmust reference entities that belong to the authenticated useruserIdis automatically assigned from JWT token and cannot be modified
Base URL: /api/v1
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| POST | /auth/register |
Register a new user | No |
| POST | /auth/login |
Login and get JWT token | No |
| POST | /auth/change-password |
Change user password | Required |
| Method | Endpoint | Description | Authentication | Authorization |
|---|---|---|---|---|
| GET | /users |
Get all users | Required | Any |
| GET | /users/:id |
Get user by ID | Required | Any |
| PATCH | /users/:id |
Update user | Required | ADMINISTRATOR or own profile |
| DELETE | /users/:id |
Delete user | Required | ADMINISTRATOR or own profile |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| GET | /states |
Get all states | Required |
| GET | /states/my |
Get current user's states | Required |
| GET | /states/:id |
Get state by ID | Required |
| POST | /states |
Create new state | Required |
| PATCH | /states/:id |
Update state | Required (owner only) |
| DELETE | /states/:id |
Delete state | Required (owner only) |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| GET | /task-types |
Get all task types | Required |
| GET | /task-types/my |
Get current user's task types | Required |
| GET | /task-types/:id |
Get task type by ID | Required |
| POST | /task-types |
Create new task type | Required |
| PATCH | /task-types/:id |
Update task type | Required (owner only) |
| DELETE | /task-types/:id |
Delete task type | Required (owner only) |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| GET | /tasks |
Get all tasks | Required |
| GET | /tasks/my |
Get current user's tasks | Required |
| GET | /tasks/:id |
Get task by ID | Required |
| POST | /tasks |
Create new task | Required |
| PATCH | /tasks/:id |
Update task | Required (owner only) |
| DELETE | /tasks/:id |
Delete task | Required (owner only) |
Note: All endpoints require JWT authentication except registration and login. Include the JWT token in the Authorization header as Bearer <token>.
Easily set up a local development environment with single command!
- Clone the repo
npm run docker:devπ
Visit localhost:4000 or if using Postman grab config.
Containers created:
- Postgres database container
- Node (v16 Alpine) container with running RESTful API service
- Node container instance to run tests locally or in CI
- Express framework
- TypeScript v4 codebase
- TypeORM using Data Mapper pattern
- Docker environment
- JWT authentication and role-based authorization
- Request validation middleware
- Consistent error response schema
- Unit and integration tests with Mocha and Chai
- Linting with ESLint
- Prettier code formatter
- Git hooks with Husky and lint-staged
This section contains detailed reports and documentation for practical assignments:
- Workshop 5 - Expanding the API
- Workshop 6 - Expanding the API