Nest-Jo is a robust open-source project aimed at simplifying and optimizing the development and deployment processes for NestJS applications within a containerized environment. The project leverages Docker for seamless orchestration of services like NestJS, PostgreSQL, and Redis, enhancing communication and data persistence. With optimized TypeScript build configurations and tailored Docker setups for both development and production environments, Nest-Jo streamlines the build efficiency, maintains code scalability, and ensures secure deployment of NestJS applications. By providing clear structures, compiler options, and efficient Docker containers, Nest-Jo proves to be a valuable tool for developers seeking a hassle-free and organized approach to NestJS application development and deployment.
Features
Feature
Description
โ๏ธ
Architecture
Nest-jo follows a modular architecture based on NestJS framework, enhancing maintainability and scalability. Utilizes Docker for containerization, optimizing development and deployment workflows.
๐ฉ
Code Quality
The codebase maintains high quality with TypeScript for type safety, eslint for linting, and Prettier for code formatting. Follows consistent style guidelines and leverages decorators for cleaner code.
๐
Documentation
Documentation is extensive, covering setup instructions, API endpoints, and codebase structure. Utilizes Compodoc for generating API documentation, ensuring clear understanding for developers.
๐
Integrations
Key integrations include @nestjs/typeorm for database interactions, passport-local and passport-jwt for authentication, and Swagger for API documentation. Integrates Redis for caching data efficiently.
๐งฉ
Modularity
The codebase exhibits high modularity with reusable modules and services. Utilizes decorators for dependency injection, promoting code reusability and separation of concerns. Enhances maintainability and flexibility.
๐งช
Testing
Testing is comprehensive with Jest and Supertest for API testing. Employs ts-jest for TypeScript support in Jest. Includes unit tests for functions and integration tests for endpoints.
โก๏ธ
Performance
Performance is optimized through efficient database queries with TypeORM, caching with Redis, and rate limiting with express-rate-limit. Utilizes argon2 for secure password hashing, enhancing security without compromising speed.
๐ก๏ธ
Security
Implements security measures such as CSRF protection, CORS policies, and helmet for HTTP header protection. Utilizes JWT for secure authentication and authorization, guarding against unauthorized access.
๐ฆ
Dependencies
Key dependencies include TypeORM for database management, NestJS for application framework, and winston for logging. Utilizes Docker and docker-compose to streamline development environments.
Orchestrates services for NestJS, PostgreSQL, and Redis in a Docker environment. Defines networks, volumes, and dependencies to ensure seamless communication and data persistence. Supports efficient development by mapping local directories to container paths.
Server with a custom image on port 3000, Postgres with defined environment variables, and Redis with a specific command and password. Settings help orchestrate development services.
Sets base image to Alpine, installs dependencies with pnpm, builds app, prunes dev dependencies, and prepares production environment with built files. Configures entry point and user settings.
Defines project structure and compiler options for NestJS. Specifies source root and deletes the output directory. Enhances project organization and compilation efficiency.
Orchestrates production environment for NestJS server, PostgreSQL, and Redis cache.-Configures Docker containers, network, environment variables, and persistent volumes.-Facilitates secure communication and data storage between services.
Defines paths for module resolution and configuration settings to build a Nest.js application with proper module organization and TypeScript compilation.
Orchestrates project scripts for building, testing, and running the NestJS application. Manages linting, formatting, and database migrations using TypeORM. Dependencies ensure robustness, security, and expressiveness of the project.
Manages database migrations, testing, and Docker operations for development and production environments. Enables creating, running, and reverting migrations, running tests, interacting with Redis, and managing Docker containers.
Initiates** NestJS application with custom logger, CORS config, database migrations, cookies parsing, security headers, and environment logging. Applies global pipes, filters, and interceptors. Listens on defined port.
Defines root module with components for configuration, database, Redis, authentication, user, events, cart, payment, ticket, reservation, and transaction management, along with request throttling. Orchestrates modules for key application functionalities within NestJS project.
Orchestrates payment operations by connecting user data. Imports modules for booking, transactions, and tickets, vital for payment services, ensuring smooth processing within the NestJS application architecture.
Tests PaymentServices processPayment method based on cart total, generating payment results for different scenarios defined by status and detail messages. Enhances validation and accuracy of payment processing functionality within the repositorys NestJS architecture.
Defines sort order options with ASC and DESC values for modular, readable code in the repository architecture, enhancing the data sorting functionality.
Defines event category types. Categorizes sports events such as Archery, Athletics, and more. Crucial for structuring and categorizing data in the Nest.js projects architecture.
Extracts user ID from the request in a Nest.js apps route handler. It helps access user data securely without direct request object manipulation, enhancing application security.
Enables defining user roles for route handlers in the Nest.js architecture. Uses ROLE_KEY constant to store role metadata. Role decorator assigns specified user roles. Supports maintaining clean and secure role-based access control within the applications common decorators.
Defines a custom exception class for invalid login credentials, inheriting from NestJSs HttpException. Handles unauthorized access with a clear error message. Crucial for maintaining codebase integrity and enhancing user experience within the Nest-JO repositorys architecture.
Implements HTTP exception handling for logging and formatting error responses in different environments. Logs error details and returns specific messages based on environment settings.
Handles HTTP exceptions by providing custom error response messages. Determines if the exception is a BadRequestException to extract detailed errors. Constructs error response with timestamp, message, and optional debugging info for non-production environments.
Limit, offset, sortBy, sortOrder, filterBy, and filterValue. Utilizes class-validator for input validation. Integral to handling data retrieval and query customization within the projects architecture.
Defines token configuration interface with secret keys and expiration times for access and refresh tokens, crucial for managing authentication within the NestJS applications security module. Influences token handling and enhances security by encapsulating essential token details.
Defines payment result and process response interfaces for reservation status handling in the booking system. It specifies payment status, details, and optional payment identifiers and reservations associated with the payment process.
Defines KeyValuePairs interface for a collection of key-value pairs in the parent repositorys architecture. It allows the use of any type as values, aiding in data management within the system.
Configures Winston logger for different environments and output formats, adjusting logging level dynamically. Integrates file and console transports, with JSON and colorized formats, enhancing logging capabilities in the Nest JS repository.
Implements** logging with Winston for the repository. Logs info, error, warn, debug, and verbose messages. Enhances centralized logging and debugging capabilities for the project architecture.
Defines a global module aggregating essential services, including user management, data encryption, payments, and Redis operations. Enables seamless access to these services across the application.
Implements a module for managing reservation details in Nest.js by importing relevant modules and entities, solely focusing on providing the ReservationDetailsService as a provider within the applications architecture.
Manages reservation details creation and retrieval within the repository structure. Creates reservation details from reservation and cart items, ensuring event and reservation existence. Allows finding reservation details by ID with related event and reservation data.
Implements reservation details creation, retrieval, handles missing events, and throws NotFoundException if needed. Uses repositories for data access. Maintains atomic operations while ensuring accurate reservations from cart items.
Defines reservation details entity with associations to reservation and event, including price formula, title, price, description, creation and update timestamps. Centralizes reservation data structure within the NestJS architecture for efficient management and retrieval.
Defines UpdateReservationDetailsDto for reservation details updating, extending CreateReservationDetailsDto with optional properties. Part of the reservation-details module in nest-jo repository architecture.
Tests user-related operations with pagination, filtering, updates, and deactivation. Validates user retrieval, updating, deactivation, and error handling. Essential for ensuring correct user management functionality within the NestJS application.
Defines a module for user management within the NestJS application. Imports necessary entities and services, registers related controllers, providers, and authentication strategy. Facilitates user-related functionality within the applications modular architecture.
Manages user data retrieval, updates, and deactivation with error handling. Utilizes query options for pagination and filtering within the NestJS architecture, facilitating smooth user management operations.
Validates, retrieves, updates, and deactivates users via the UsersService.-Employs pagination, filtering, and error handling for user data operations.-Utilizes User entity repository and QueryHelperService.
Retrieves all users with filtering, finds a single user, updates user information, and deactivates users. Implements role-based access control using guards for varying user permissions within the NestJS applications architecture.
Email, names, role, activity status, and transaction details. Represents relationships with Cart, Reservations, and Transactions. Tracks creation and login timestamps. Enforces data privacy by excluding sensitive fields in responses.
Defines an UpdateUserDto class extending CreateUserDto for user updating. Marks all properties as optional. Fulfills the DTO pattern in the users module of the Nest.js framework.
Defines a DTO for creating users, enforcing validation rules on user data and role assignment. This module enhances the codebase by ensuring data integrity and consistency during user creation processes.
Defines a cart items module handling entities like CartItem, Event, and ReservationDetails. Integrates Controllers and Services, imports related modules, and provides essential functionalities for managing cart items within the NestJS architecture.
Manages cart items by adding, updating, and removing them from carts. Ensures quantity availability and handles price calculations. Integrates with cart, event, and pricing services for a seamless shopping experience.
Manages cart items with endpoints for adding, retrieving, updating, and removing items in a users cart. Implements authorization checks using guards. Works seamlessly with the parent repositorys modular structure for efficient cart management.
Create, fetch, update, remove. Handles user authorization and returns detailed exceptions when needed. Interacts with CartItemsService for seamless cart item operations within the repositorys Nest.js architecture.
Defines shopping cart item entity with relationships to cart, event, reservations. It includes fields for price, quantity, timestamps, and a pricing formula enum. This entity encapsulates crucial data for managing cart items within the wider application context.
Defines DTO for creating a cart item with user and event IDs, quantity, and price formula validation using class-validator. It enforces data integrity for adding items to the shopping cart within the NestJS e-commerce application.
Defines DTO for cart item updates, extending CreateCartItemDto with optional properties. Key to managing cart items in the nest-jo repositorys modular architecture.
Processes user reservations including payment, ticket generation, and cleanup. Utilizes various services to manage cart items, transactions, and reservations. Implements steps such as creating, finalizing bookings, and preventing duplicates to ensure smooth reservation handling.
Create, find all,find all admin, and find one. Mocks service responses for successful, unauthorized, and non-existent scenarios. Ensures correct service method calls with user and reservation IDs, pagination.
Defines a service handling reservation operations in the Nest.js project. Implements functionality to generate, find, save reservations and provides admin-specific functions. Critical features include user-specific operations and error handling for seamless reservation management.
Processes user reservations, creates bookings, prevents duplicates, and cleans up post-payment in the repositorys architecture. Manages transactions, payments, events, and users seamlessly.
Processes user reservations, retrieves, saves, and finds reservations by user ID or admin. Handles pagination and filtering. Ensures accurate reservation data retrieval with user-specific and admin-specific fields.
Defines a module managing reservations, including controllers, services, and entities like Reservation and Event. Imports related modules, registers controllers and services, and exports Reservation-related services for the parent repositorys architecture.
Manages reservations, handles creation, retrieval, and filtering for users and admins. Utilizes guards for authorization. Key features include create, find-all, find-all-admin, find-all-data, and findOne reservation functions.
Defines entities for reservations, linking to user, details, transaction, cart item, and ticket. Tracks creation and update timestamps. Key part of the repositorys module structure for managing reservation-related data in the system.
Defines a DTO for reservation creation, validating user, cart item, total price, and payment ID. Essential for ensuring data integrity and user input correctness within the reservation module.
Manages event creation, retrieval, update, and deletion with access control. Handles event pricing calculation based on specified formulas. Facilitates filtering and pagination of events.
Creates, updates, retrieves, deletes prices based on formulas. Computes prices from base price and multipliers. Offers error handling for events and prices not found.
Creates, finds, updates, and removes events, ensuring data integrity. Handles conflicts and errors gracefully. Improves search efficiency by filtering events. Caches event data for quick access.
Creates, retrieves, updates, and deletes events. Includes methods to ensure title uniqueness, handle pagination and filtering, and interact with Redis cache for efficient data retrieval.
Defines an event management module within the repository. Manages events data using TypeORM. Provides services for handling events, event prices, and sales. Exports services for broader application usage.
Manages event sales and revenue by processing ticket purchases, updating revenue, and deducting ticket quantities. Offers methods to update revenue for specific events, deduct ticket quantities, and determine deduction factors based on price formulas.
Implements event ticket processing, revenue calculation, and quantity deduction. Utilizes mocked data for testing. Ensures accurate handling of ticket sales and revenue updates in the NestJS repositorys event-sales service.
Tests EventPricesService functionality in the NestJS app. Creates, retrieves, updates, and deletes event prices with validations. Handles events and prices using repositories and enforces necessary business logic.
Defines event pricing entity with relationships and attributes for the NestJS project. Handles event price details with associations to the event entity, including price formula selection and actual event pricing.
Defines Event entity with attributes like title, descriptions, pricing, dates, quantities, revenue, and relationships to prices, reservations, and cart items for efficient event management within the NestJS repositorys modular architecture.
Validates and structures event creation data as a DTO. Enforces specific field requirements like title length, pricing, dates, and category type enum using class-validator. Essential for maintaining data integrity in the events module of the repository.
Manages ticket generation for approved reservations. Utilizes encryption, user, and reservation services. Generates tickets based on reservation status. Crucial for handling ticket creation in the overall application architecture.
Defines a module handling tickets, creating reservations. Imports modules to manage transactions, users, and reservation details. Resolves circular dependencies using forwardRef. Exports TicketsService for use within the repository architecture.
Implements ticket generation for approved reservations and handles non-approved cases with appropriate exceptions.-Generates tickets for reservations with necessary user and reservation validations.-Creates new tickets with specific keys and QR codes for secure ticketing.
Tests TransactionsControllers findAll method, ensuring correct user transactions retrieval with specific filters and sorting. Mocks TransactionsServices findAll method to return expected results and checks the method calls.
Defines a module managing transactions, with services for transactions, reservation details, and query handling. Imports entities from TypeORM and modules for reservations and tickets. Provides necessary controllers and services for transaction management.
Manages transactions, creating and finding by reservation ID, and retrieving with pagination. Calculate cart total and select specific fields. Enhances the user experience through efficient handling of payment-related operations within the parent repositorys architecture.
Create, find by ID, calculate total, and fetch all with pagination. Enhances user and cart interactions. Integrates with repository and query services for seamless data management within the repositorys NestJS architecture.
Manages user transactions by retrieving filtered results with pagination. Uses AccessTokenGuard for security. Collaborates with TransactionsService to fetch and provide transaction data based on specified user ID and filtering criteria.
Defines Transaction entity linking Users and Reservations, tracking payment status and amount. Facilitates creating and updating transactions with timestamps. Central to managing transaction-related data within the repositorys architecture.
Defines CreateTransactionDto capturing transaction data for the Nest-jo repository. Orchestrates data transfer functionality within the transactions module architecture, facilitating seamless communication between various components.
Defines UpdateTransactionDto extending PartialType from @nestjs/swagger, inheriting properties from CreateTransactionDto. Located in src/modules/transactions/dto, it shapes data for updating transaction details in the NestJS architecture of the parent repo.
Manages and interacts with users shopping carts in the Nest.js repository. Features include cart retrieval, creation, verification, saving, and deletion. Handles exceptions for cart not found scenarios.
Defines a module managing carts. Imports TypeOrmModule for Cart entity, registers CartsService as a provider, and exports CartsService for use across the application.
Defines a shopping cart entity with user association and cart items. Records creation and last update timestamps. Central to managing user shopping activities in the applications modular architecture.
Defines a TypeORM DataSource configuration for PostgreSQL in the NestJS project. Retrieves database connection details from environment variables using ConfigService. Specifies database connection settings like host, port, username, password, database name, entity, and migration paths.
Executes database migrations for the Nest.js app using TypeORM. Logs initialization, migration execution, and handles failures gracefully. Integrated as a critical step in managing database schema changes within the repositorys architecture.
Establishes database connection via TypeORM using PostgreSQL for the NestJS app. Dynamically loads config from env vars using ConfigService. Enables async configuration and defines entity paths for seamless integration.
Handles Redis caching with set, get, delete operations, and fetching cached data. Implements safe JSON parsing and event-based cache clearing. Interacts seamlessly with the NestJS architecture for efficient data caching and retrieval.
Sets up Redis client and service using environment variables. Configures Redis client with host, port, and password. Encapsulates client creation logic with ConfigService access. Exportable for use across modules in the NestJS application.
Implements a migration that creates a reservation_details table for storing detailed reservation information, including event and pricing data. It ensures table creation only if not already existing and includes relationships with the events and reservations tables for database management.
Manages database migration to create a table for storing cart items, cart references, event data, and pricing details. Ensures table creation and handles rollback.
Creates reservations table schema to store reservation details like user, cart item, transaction, reservation details, and ticket. Implements migration methods to set up and remove the table in a database using TypeORM.
Creates tickets table for storing ticket details with reservation and security references. Manages creation and removal of the table via up and down migrations. Incorporated in the application's database schema for ticket management.
Creates events table schema for managing event details. Ensures a unique events table with columns for eventId, title, descriptions, pricing, dates. Utilizes Enum and QueryRunner for CRUD operations.
Implements user table creation with user details columns. Tables are created only if not existing, with role enum type check. The migration can create or drop the users table, facilitating user data management in the app.
Creates a cart table in the database to manage shopping cart information, user references, and timestamps for creation and updates. Includes methods to apply and revert the table creation.
Defines a migration scheme to create an event_prices table, facilitating event pricing management. Ensures table existence, includes event ID, price formula, and price columns. Enables migration rollback by dropping the table.
Implements foreign key constraints for reservations and tickets tables, ensuring data integrity. Enables linking reservations to users, transactions, and tickets. Supports reverting changes if needed.
Implements foreign key constraints migration for reservations and tickets tables in the database. Ensures data integrity and consistency during database operations by adding or removing foreign key constraints based on the migration direction.
Implements migration tests for creating/dropping cart_items table. Verifies creation only if table doesn't exist, avoids duplicate creation. Validates proper table drop operation. Facilitates database schema evolution within the repository structure.
Ensures creation of reservation_details table if absent, avoiding duplication checks. It relies on TypeORM and constants for migrations, enhancing database schema management in the NestJS architecture.
Implements migration to handle reservations table creation and deletion based on table existence status. Verifies table status before executing create or drop statements. Ensures database schema consistency during application lifecycle.
Implements migration tests for creating and dropping events table in the database. Verifies table creation based on existence, ensuring proper database schema management in the nest-jo repository.
Implements migrations to create/drop event_prices table based on existence. Verifies table creation and query execution. Maintains data integrity within the Nest.js backend architecture.
Implements migrations for creating and dropping a tickets table in the database. Verifies existence before creating. Part of the database module structure within the parent repository.
Implements migration tests ensuring creation/dropping of transactions table based on existing state. Impacts database schema evolution, validating migration correctness and data integrity within repositorys architecture.
Validates and performs database migrations for the cart table. Verifies table existence before creating, and drops the table on rollback. Enhances data integrity for the NestJS application.
Tests creation of users table existence and creation in the database using TypeORM migrations. Verifies up and down methods handle table creation and deletion correctly based on existing table state.
Tests for QueryHelperService in nest-jo repository validate building query options, where conditions, and nested orders. They ensure accurate generation of queries based on provided criteria, contributing to the robustness and reliability of database interactions within the application.
Optimizes filtering and sorting operations for database queries in Nest.js by generating dynamic query options based on pagination data. This service helps streamline querying processes by constructing conditions for filtering, sorting, and pagination.
Defines constants for node environment variables, aiding environment-specific logic in the parent repositorys architecture. Includes NODE_ENV, DEV_ENV, and PROD_ENV for distinguishing between development and production environments.
Defines price formulas and default page sizes for entities in a Nest.js application. Implements formulas and multipliers for pricing, along with fixed page sizes for users, reservations, and events.
Defines migration database enum types with values. Generates SQL commands to create enum types if they dont exist, ensuring data consistency. Key for managing database schema integrity in the NestJS projects architecture.
Tests ConvertUtilsService for accurate conversion of days to seconds and date strings to Date objects. Validates correct conversion and error handling, ensuring reliable utility functions align with the parent repositorys architecture.
Convert Utils Service in src/utils handles conversions like days to seconds and date strings to Date objects. This service enriches the utility layer by providing essential functions for converting data formats seamlessly within the Nest-jo repository architecture.
Hashing passwords with Argon2, verifying hashed passwords, generating UUIDs, creating secure keys for users, and generating QR codes from secure keys. Complements user security within the Nest-jo architecture.
Tests encryption functions using argon2 for secure password hashing and verification. Part of the security module to ensure data security. Designed to hash and verify passwords to enhance user authentication.
Enforces content creator ownership by verifying user identity against content ownership before allowing access to specified routes in the Nest.js application.
Provides role-based, creator, and access token guards for secure API access control in the security module. Supports granular permission handling to enforce security policies across the Nest.js application.
Tests RoleGuard behavior based on user roles. Verifies access allowance or denial. Uses Nest.js testing utilities and reflector to validate role-based access control logic.
Enables role-based access control in the Nest.js app. Determines if users can access routes based on their roles defined with decorators. Utilizes metadata and user roles to restrict or allow access.
Confirms true if user ID matches content creator, throws NotFoundException otherwise, or when user is missing. Enhances app security by restricting access based on creator status.
Implements cookie management functions for extracting, setting, and clearing refresh tokens within the NestJS security module. Functions leverage ConfigService for settings and ConvertUtilsService for conversions, ensuring secure and efficient cookie handling in the application.
Manages HTTP cookies for handling user authentication. Extracts and sets refresh token cookies securely with configurable expiration. Ability to clear refresh token cookies for enhanced security.
Implements TokenManagementService to handle token creation and verification with JwtService and ConfigService. It ensures secure generation of access and refresh tokens based on specified secrets and token expiration times.
Manages JWT tokens and their operations. Generates tokens for users, refreshes tokens, and validates refresh tokens. Implements secure token handling and error responses within the repositorys security architecture.
Tests storing, verifying, and removing refresh tokens in Redis for the NestJS applications security module. Mocks services and config for unit testing. Maintains secure token management within the broader application structure.
Stores tokens with TTL, verifies their validity, and removes expired tokens. Dependencies: RedisService for Redis interactions, ConvertUtilsService for value conversions, and ConfigService for configuration access.
Manages JWT tokens for creating, refreshing, and verifying tokens. Utilizes ConfigService for secrets and expiration times. Enhances security and authentication within the repositorys architecture.
Implements token handling logic for authentication and refresh token management. Validates, generates, and refreshes tokens, ensuring user access and security. Supports seamless token creation and storage in Redis for efficient authentication handling in the NestJS architecture.
Enables rate limiting with a 10-requests-per-minute configuration, enhancing API security and performance. Integrated within the Nest-JO repositorys architecture to control incoming traffic effectively.
Manages user authentication, including signup, login, password updates, access token generation, token refresh, logout, and user deletion. Interfaces with the AuthService and TokenService to provide these essential user-related operations securely.
Creating user, logging in, updating password, getting refresh token, refreshing token, and logging out with appropriate service interactions for the nest-jo repositorys auth functionality.
Implements authentication logic for signing up, logging in, updating passwords, and logging out users. Interacts with user, encryption, token, cookie, cart, and refresh token services. Handles various exceptions like unauthorized access and invalid credentials.
Manages user authentication, registration, login, password updates, logout, and deletion. Utilizes user repositories, encryption, tokens, cookies, and refresh tokens for various operations in the Nest.js repositorys security and authentication context.
Defines authentication module managing services and controllers for user authentication, utilizing TypeORM for user entity, alongside other services like JwtService and CookieService. Imports CartsModule and CommonModule for extended functionality within the NestJS application.
Defines SignUpDto for user registration with validation rules supporting first name, last name, email, password, and optional role using class-validator.
Defines UpdatePasswordDTO with old and new password fields, using class-validator to ensure they are non-empty strings and meet strong password criteria. This DTO facilitates secure user password updates within the NestJS projects security module.
Implements access token validation strategy using JWT for user authentication. Validates user existence and token version, throwing exceptions when needed.Integration with TypeORM and NestJS configuration services.
Validates and authorizes access tokens using JWT for user authentication. Implements a Passport strategy to verify token validity, ensuring users exist and tokens match. Mapped to User repository and app configuration for seamless integration within the NestJS architecture.
Verifies API endpoints by simulating HTTP requests using the NestJS testing framework. Initiates a testing module with the AppModule to validate the GET / route, ensuring a successful response and the expected message.
Configures Jest for end-to-end testing in the NestJS project. Specifies file extensions, test environment, test file matching regex, and transformation settings for TypeScript files.
Getting Started
System Requirements:
TypeScript: version x.y.z
Docker & Docker Compose
Nodejs
Nestjs CLI
Installation
1. Clone the Git repository:
git clone https://github.com/Binary-Blade/nest-jo
cd nest-jo
2. Install backend dependencies:
pnpm install
3. Configure environment variables:
Rename the .development.env.example and .production.env.example files to .development.env and .production.env, then update these files with your connection information.