🚀 Kickstart your NestJS journey with this comprehensive template! 🚀
This template is designed to provide you with a solid foundation for building scalable and maintainable server-side applications using NestJS. It comes packed with essential features to streamline your development process.
-
🔑 JWT Authentication: Authorization is handled using JWT and passport-jwt, ensuring secure and stateless authentication.
-
🔑 Sessions: Sessions are handled using Redis/Memory to store user sessions and manage them.
-
🛡️ Role-Based Access Control: Effortlessly manage user roles and permissions to ensure the right access levels.
-
🌐 Internationalization Support: Seamlessly support multiple languages and locales to reach a global audience.
-
📜 Swagger Documentation: Automatically generated API documentation to help you and your team understand and use the API effectively.
-
🛠️ Modular Architecture: Clean and organized structure to facilitate scalability and maintainability.
-
⚡ High Performance: Optimized for speed and efficiency, ensuring your application runs smoothly.
-
🐳 Docker: Docker compose file for development environment.
This template is structured to help you quickly start developing your NestJS application. Here's how you can make the most of it:
-
Apps: Add new apps in the
apps
directory. Each app should encapsulate related functionality, including modules, common types, guards, interceptors, etc. -
Modules: Add new features by creating modules in the
<app-name>/src/modules
directory. Each module should encapsulate related functionality, including controllers, services, and repositories. -
Controllers: Define your API endpoints in controllers. Place them in the respective module's directory under
app-name/src/modules
. -
Services: Implement your business logic in services. These should also be placed within the module's directory.
-
Repositories: Interact with the database using repositories. Define them in the module's directory and use Prisma or TypeORM for database operations.
-
DTOs (Data Transfer Objects): Define DTOs in the
dto
directory within each module to validate and type-check incoming data. -
Guards and Interceptors: Implement guards and interceptors in the
libs/common/src/guards
directory to handle cross-cutting concerns like authentication and logging. -
Configuration: Manage application configuration using the
ConfigModule
inapps/app-name/src/config
. Environment variables can be defined in.env
files. -
Internationalization: Add translations in the
libs/i18n
directory to support multiple languages. -
Swagger Documentation: Automatically generate API documentation by annotating your controllers and DTOs with Swagger decorators.
- Primary API application
- Port: 3000
- Swagger: http://localhost:3000/api
- Administrative API
- Port: 3001
- Swagger: http://localhost:3001/api
To get started with this template, follow these steps:
-
Create Your Repository: This is a GitHub template repository. Use it to create your own repository by clicking the "Use this template" button on GitHub.
-
Clone Your Repository: Clone your newly created repository to your local machine.
git clone <your-repository-url>
-
Install Dependencies: Navigate to the project directory and install the necessary dependencies.
cd <your-repository-name> pnpm install
-
Set Up Environment Variables: Create a
.env
file in the root directory and configure your environment variables. Refer to.env.example
for guidance. -
Database Setup: Ensure your database is running and configured correctly. Use Prisma or TypeORM migrations to set up your database schema.
-
Run the Application: Start the application in development mode.
pnpm start:dev
-
Access Swagger Documentation: Visit
http://localhost:<3000/3001>/api
to view the automatically generated Swagger documentation. -
Explore and Customize: Explore the codebase, add new features, and customize the template to fit your project needs.
Explore these features and more to build a powerful and flexible application with NestJS! 🚀