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
.env
file 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": "john.doe@example.com", "phoneNumber": "1234567890", "password": "password", "country": "USA" }
-
🔑 Sign In
POST /account/sign-in
Request Body:
{ "email": "john.doe@example.com", "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
file
field -
📥 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.