HealthTaskentity with TaskStatus enum (DRAFT, ACTIVE, ARCHIVED)Categoryentity for task categorization- Proper TypeORM relationships and decorators
CreateTaskDto- Validates xlmReward between 0.1 and 5.0UpdateTaskDto- Extends CreateTaskDto with optional status fieldListTasksDto- Extends PaginationDto with category filter
- ✅ Uses
@InjectRepository(HealthTask)with standard TypeORM Repository - ✅ Uses QueryBuilder directly in service for active tasks filtering
create()- Creates tasks with DRAFT status (ADMIN/HEALER)findAll()- Returns only ACTIVE tasks with pagination and category filterfindOne()- Gets task by ID (public, returns any status)update()- Owner or ADMIN can update; only ADMIN can publishremove()- Archives task (ADMIN only via guard) - sets status to ARCHIVED
- POST
/tasks-@Roles(Role.ADMIN, Role.HEALER) - GET
/tasks- Public, returns only ACTIVE tasks - GET
/tasks/:id- Public, returns task regardless of status - PATCH
/tasks/:id-@Roles(Role.ADMIN, Role.HEALER)- Owner or ADMIN - DELETE
/tasks/:id-@Roles(Role.ADMIN)- Archives task
- Migration file for database tables
- Comprehensive unit tests (18 tests, all passing)
- API documentation (HEALTH_TASKS_API.md)
- Module registered in AppModule
- ✅ TasksService injects
@InjectRepository(HealthTask)repository - ✅ GET
/tasksuses QueryBuilder withWHERE status = 'ACTIVE' - ✅ xlmReward validated between 0.1 and 5.0 in DTO
- ✅ Only admins can publish (change status to ACTIVE)
- ✅ GET
/taskssupports pagination and category filter
- ✅ Added
@Roles(Role.ADMIN, Role.HEALER)to PATCH endpoint for consistency - ✅ Removed duplicate role check in
remove()- now handled by guard only - ✅ Fixed repository injection - using standard TypeORM Repository pattern
- ✅ Moved QueryBuilder logic directly into service (removed custom repository)
- ✅ Updated test descriptions to match actual behavior (archive vs soft delete)
- ✅ Added test for
findOne()returning non-ACTIVE tasks - ✅ Added test for
remove()when task doesn't exist
Test Suites: 2 passed, 2 total
Tests: 18 passed, 18 total
- Service: 13 tests covering create, findAll, findOne, update, remove
- Controller: 5 tests covering all endpoints
- Edge cases: Non-existent tasks, non-ACTIVE status, invalid categoryId, authorization
- Run database migrations:
npm run migration:run - Seed categories data
- Test endpoints with Postman/Insomnia
- Consider adding e2e tests