Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonidarodda/nestjs-template
NestJS template for projects with TypeOrm, featuring account management, authentication, emailing, caching, compression, scheduled tasks, and S3.
https://github.com/tonidarodda/nestjs-template
caching compression emailing nest nestjs nestjs-backend s3 swagger tasks template template-project typeorm websocket
Last synced: 3 months ago
JSON representation
NestJS template for projects with TypeOrm, featuring account management, authentication, emailing, caching, compression, scheduled tasks, and S3.
- Host: GitHub
- URL: https://github.com/tonidarodda/nestjs-template
- Owner: ToniDarodda
- License: apache-2.0
- Created: 2024-08-02T14:32:45.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T09:02:26.000Z (4 months ago)
- Last Synced: 2024-10-11T18:05:54.740Z (3 months ago)
- Topics: caching, compression, emailing, nest, nestjs, nestjs-backend, s3, swagger, tasks, template, template-project, typeorm, websocket
- Language: TypeScript
- Homepage:
- Size: 397 KB
- Stars: 15
- Watchers: 1
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---
# NestJS Template
![NestJS](https://img.shields.io/badge/NestJS-7E1E9C?style=for-the-badge&logo=nestjs&logoColor=white)
![TypeORM](https://img.shields.io/badge/TypeORM-FF7A59?style=for-the-badge&logo=typeorm&logoColor=white)
![PostgreSQL](https://img.shields.io/badge/PostgreSQL-336791?style=for-the-badge&logo=postgresql&logoColor=white)
![PNPM](https://img.shields.io/badge/PNPM-4D4D4D?style=for-the-badge&logo=pnpm&logoColor=white)
![License](https://img.shields.io/badge/License-LICENSED-green?style=for-the-badge)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.
## Features
- ๐ค **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## ๐ Getting Started
### Prerequisites
- Node.js (v14 or higher)
- PostgreSQL
- Email service credentials (e.g., Gmail SMTP)
- AWS S3 credentials for file upload### Installation
1. Clone the repository
```sh
git clone https://github.com/ToniDarodda/NestMonolithTemplate.git
cd NestMonolithTemplate
```2. Install dependencies
```sh
pnpm install
```3. Update the `.env` file in the root directory and configure environment variables:
```sh
EMAIL_PASS='Your password'
```### Running the Application
1. Start the PostgreSQL database
2. Run the application
```sh
pnpm run start:dev
```3. The API will be available at `http://localhost:3000`
### API Documentation
The API documentation is available at `http://localhost:3000/api`.
## ๐ Usage
### User Account Management
- **๐ช Sign Up**
```http
POST /account/sign-up
```Request Body:
```json
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"phoneNumber": "1234567890",
"password": "password",
"country": "USA"
}
```- **๐ Sign In**
```http
POST /account/sign-in
```Request Body:
```json
{
"email": "[email protected]",
"password": "password"
}
```- **๐ค Get User Information**
```http
GET /account
```Requires JWT Authentication and User Role
- **๐ Update User Information**
```http
PATCH /account
```Requires JWT Authentication and User Role
Request Body:
```json
{
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "1234567890",
"country": "USA"
}
```- **๐๏ธ Delete User Account**
```http
DELETE /account
```Requires JWT Authentication and User Role
### File Upload to S3
- **๐ค Upload File**
```http
POST /file/upload
```Requires JWT Authentication
Request Body: Form-data with `file` field
- **๐ฅ Get File**
```http
GET /file/:fileName
```Requires JWT Authentication
## ๐งช Testing
To run the tests, use the following command:
```sh
pnpm run test
```## ๐ ๏ธ Scripts
- `๐จ 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## ๐ License
This project is licensed under the UNLICENSED License.
## ๐ค Author
[Toni Da Rodda](mailto:[email protected])
## ๐ ๏ธ Icons
- ๐ 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](mailto:[email protected]).
---