This project is a NestJS template that includes various features such as user account management, authentication, authorization, email integration, caching, compression, centralized error handling, input validation, logging, scheduled tasks, and file upload to S3.
- π€ User Account Management
- Sign-up, Sign-in, Get user, Update user, Delete user
- π Authentication and Authorization
- JWT-based authentication, role-based authorization
- βοΈ Email Integration
- Send emails using Nodemailer
- πΎ Caching
- Optimize responses for frequently requested endpoints
- β Centralized Error Handling
- Global exception filter to handle all errors consistently
- β
Input Validation
- Validate user inputs using class-validator
- π Logging
- Log application activities and errors
- π Compression
- Compress HTTP responses to improve performance
- β° Scheduled Tasks
- Perform periodic tasks using CRON jobs
- π€ File Upload to S3
- Upload and retrieve files from Amazon S3
- Node.js (v14 or higher)
- PostgreSQL
- Email service credentials (e.g., Gmail SMTP)
- AWS S3 credentials for file upload
-
Clone the repository
git clone https://github.com/ToniDarodda/NestMonolithTemplate.git cd NestMonolithTemplate -
Install dependencies
pnpm install
-
Update the
.envfile in the root directory and configure environment variables:EMAIL_PASS='Your password'
-
Start the PostgreSQL database
-
Run the application
pnpm run start:dev
-
The API will be available at
http://localhost:3000
The API documentation is available at http://localhost:3000/api.
-
πͺ Sign Up
POST /account/sign-up
Request Body:
{ "firstName": "John", "lastName": "Doe", "email": "[email protected]", "phoneNumber": "1234567890", "password": "password", "country": "USA" } -
π Sign In
POST /account/sign-in
Request Body:
{ "email": "[email protected]", "password": "password" } -
π€ Get User Information
GET /account
Requires JWT Authentication and User Role
-
π Update User Information
PATCH /account
Requires JWT Authentication and User Role
Request Body:
{ "firstName": "John", "lastName": "Doe", "phoneNumber": "1234567890", "country": "USA" } -
ποΈ Delete User Account
DELETE /account
Requires JWT Authentication and User Role
-
π€ Upload File
POST /file/upload
Requires JWT Authentication
Request Body: Form-data with
filefield -
π₯ Get File
GET /file/:fileName
Requires JWT Authentication
To run the tests, use the following command:
pnpm run testπ¨ build: Build the applicationπ§Ή format: Format the code using PrettierπββοΈ start: Start the applicationπ¨βπ» start:dev: Start the application in development modeπ start:debug: Start the application in debug modeπ start:prod: Start the application in production modeπ lint: Lint the code using ESLintπ§ͺ test: Run the testsπ¦ migration:generate: Generate a new database migrationπ migration:run: Run the database migrationsπ΅οΈββοΈ test:watch: Run the tests in watch modeπ test:cov: Run the tests and generate coverage reportπ test:debug: Run the tests in debug modeπ§ͺ test:e2e: Run end-to-end tests
This project is licensed under the UNLICENSED License.
- π Deployment
- βοΈ Configuration
- π Documentation
- π§ Maintenance
- π Security
- π« Email Integration
- π Performance Optimization
- β‘ Gain Time
Feel free to contribute to this project by submitting issues or pull requests.
For any questions or support, please contact Toni Da Rodda.