Skip to content

gusdorio/node-js-sample

Repository files navigation

Projects API

Node.js REST API for managing projects and tasks with MySQL and Redis.

Architecture

  • Node.js + Express - REST API (http://localhost:3000)
  • MySQL 8.0 - Database (localhost:3306)
  • Redis - Caching (localhost:6379)
  • Sequelize - ORM

API Overview

This REST API provides comprehensive project and task management capabilities with a clean, intuitive interface. The application offers full CRUD operations for both projects and tasks, including support for hierarchical task structures with subtasks.

Key Features

  • Project Management: Create, read, update, and delete projects with detailed information
  • Task Management: Full task lifecycle management with project association
  • Subtask Support: Create and manage subtasks within parent tasks for better organization
  • GitHub Integration: Link GitHub repositories to projects and manage repository associations
  • Redis Caching: High-performance caching for GitHub API responses (10-minute TTL)
  • RESTful Design: Clean, predictable API endpoints following REST conventions
  • Data Relationships: Proper linking between projects, tasks, subtasks, and GitHub repositories

API Documentation

The application includes interactive API documentation powered by Swagger UI, providing a comprehensive view of all available endpoints, request/response schemas, and the ability to test API calls directly from your browser.

To access the API Documentation, while running the application:

http://localhost:3000/api-docs

The Swagger interface allows you to:

  • Browse all available endpoints organized by resource (Projects, Tasks, GitHub)
  • View detailed request and response schemas
  • Test API endpoints directly with sample data
  • Understand required parameters and data types
  • Explore the complete API functionality interactively

Available Endpoints

  • Projects: /api/projects - Complete project management
  • Tasks: /api/tasks - Individual task operations
  • Project Tasks: /api/projects/{id}/tasks - Project-specific task management
  • Subtasks: /api/tasks/{id}/subtasks - Hierarchical task relationships
  • GitHub Integration: /api/projects/{id}/github/{username} - Link and manage GitHub repositories

Environment Setup

  1. Copy the environment template:
cp .env.template .env
  1. Edit .env file with your preferred values:
DB_NAME=projects_db
DB_USER=root
DB_PASSWORD=rootpassword
MYSQL_ROOT_PASSWORD=rootpassword

# Redis Configuration
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD= (can be left empty...)
REDIS_TTL_GITHUB=600

Running the Project

Note: I has configured a Makefile on the project (which requires to be inside a linux enviroment). You could simple use docker-compose directives for running the project too; This is just for a more clear and intuitive setup.

Development Environment

make dev

Production Environment

make prod

Stop Services

make dev-down    # Stop development
make prod-down   # Stop production

Testing

The project includes a comprehensive test suite using Jest with SQLite in-memory database.

Run Tests

make dev-test           # Run all tests once
make dev-test-watch     # Run tests in watch mode
make dev-test-coverage  # Run tests with coverage report

Test Structure

  • Unit Tests: Repository layer CRUD operations
  • Database: SQLite in-memory for fast, isolated tests
  • Coverage: Tracks all src/**/*.js files except app.js
  • Mocking: Database layer mocked for testing isolation

Tests cover Project and Task entities including subtask relationships, validation, and error handling.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages