A progressive Node.js framework for building efficient and scalable server-side applications.
A robust NestJS-based server application that implements a comprehensive authentication system with role-based access control. Built with TypeScript, this application features:
- User authentication (registration, login)
- Role-based authorization (admin/user roles)
- REST API endpoints
- Automated API testing infrastructure (Playwright + TypeScript)
- Docker containerization
- PostgreSQL database integration
.
├── .github/
│ ├── actions/ # Custom GitHub Actions
│ └── workflows/ # CI/CD pipeline configurations
├── api/ # API testing infrastructure
│ ├── enums/ # Enums for URLs, endpoints, methods, etc.
│ │ ├── application-urls.enum.ts
│ │ ├── endpoints.enum.ts
│ │ ├── request-methods.enum.ts
│ │ ├── status-codes.enum.ts
│ │ └── test-tags.enum.ts
│ ├── fixtures/ # Test fixtures and data setup
│ │ ├── auth.fixture.ts
│ │ ├── global.fixture.ts
│ │ ├── merged-fixtures.fixture.ts
│ │ ├── service.fixture.ts
│ │ └── scripts/
│ ├── helpers/ # Test helpers and factories
│ │ └── factory/
│ ├── infra/ # Test infrastructure
│ │ ├── api-client.ts
│ │ └── services/
│ ├── logger/ # Custom logging
│ │ └── custom.logger.ts
│ ├── tests/ # API test suites
│ │ ├── auth-api/ # Authentication tests
│ │ └── users-api/ # User management tests
│ ├── types/ # TypeScript type definitions
│ │ ├── request.types.ts
│ │ └── user/
│ └── utils/ # Testing utilities
│ └── mocks/
├── src/ # Application source code
│ ├── auth/ # Authentication module
│ ├── users/ # Users module
│ └── middleware/ # Custom middleware
├── docker-compose.yml # Docker compose configuration
└── Dockerfile # Docker image definition
- User registration with role assignment
- JWT-based authentication
- Protected routes with Guards
- Role-based access control (RBAC)
- Playwright for API testing
- Custom fixtures for test setup
- Automated test runs with CI/CD
- Comprehensive API test coverage
- PostgreSQL integration
- In-memory database for development
- Docker container setup
- Node.js (v20 or later)
- Docker and Docker Compose
- npm/yarn package manager
# Install dependencies
$ npm ci
# Install Playwright for testing
$ npx playwright install# Start development server
$ npm run start:devThe project includes a comprehensive API testing suite:
# Run API tests
$ npm run test:apiThis project uses Docker for containerization and deployment:
# Build and start Docker containers
$ docker-compose up -d
# Stop containers
$ docker-compose downThe application includes:
- NestJS server container
- PostgreSQL database container
- pgAdmin container for database management
Required environment variables:
JWT_SECRET: Secret key for JWT tokensPORT: Application port (default: 3000)POSTGRES_PASSWORD: Database passwordPGADMIN_DEFAULT_EMAIL: pgAdmin emailPGADMIN_DEFAULT_PASSWORD: pgAdmin password
Once the application is running, visit http://localhost:3000/api for Swagger documentation.
-
Authentication:
- POST
/auth/register- Register new user - POST
/auth/login- Login user - GET
/auth/profile- Get user profile (protected)
- POST
-
Users:
- GET
/users- List users (protected) - GET
/users/:id- Get user by ID (protected) - PATCH
/users/:id- Update user (protected) - DELETE
/users/:id- Delete user (protected)
- GET
This project uses GitHub Actions for continuous integration and deployment. The pipeline includes:
- Triggers on:
- Push to main branch
- Pull requests to main branch
- Manual workflow dispatch
- Runs API tests in parallel for different test suites (@users, @auth)
- Uses Docker Compose for test environment setup
- Validates server health before running tests
- Automatically deploys to Docker Hub on successful main branch pushes
- Requires successful test completion
- Builds and pushes latest Docker image
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request