A progressive Node.js framework for building efficient and scalable server-side applications.
My Learning Project in Nest.JS. Creating an Simple Contact API, this project including Authentication based on stored token on database and automatically logout if token is expired, specify which role that can accessed some routes (can be spesifically access by 1 role or multiple role), automatically sending verification email after register and after verifed, setup configuration for using multer uploads and save the file into local, or famous cloud storage (Cloudflare R2, AWS S3, Google Cloud Storage).
- Register User
- Send Email to Verify User
- Verify User
- Send Welcome Email after User Verified.
- Login User
- Get Logged In User
- Update User Data
- Logout User
- Get All Contact & Search Contact
- Create Contact
- Get Contact
- Update Contact
- Update Contact Image
- Delete Contact
- Get All Addresses in the Contact
- Create Addresses of Contact
- Get Address
- Update Address
- Delete Address
- Make Endpoint for forgot password
- Setup Swagger UI
- Create setup for multer to upload in cloud bucket like Cloudflare R2/AWS S3/GCP Cloud Storage
You can see at doc folder or import the postman collection. or you can go to swagger api docs:
npm install
npx prisma init
DATABASE_URL="mysql://root:@localhost:3306/nest_contacts?schema=public"
# MAIL CONFIG
MAIL_HOST="yourwebserver.domain.com"
MAIL_PORT=465
MAIL_SECURE=true
[email protected]
MAIL_PASS=YourPassword
# HASHIDS CONFIG
HASHIDS_SALT=YOURSALT
# STORAGE MODE
STORAGE=local # (local, r2, s3, gcp) : local (local server), r2 (cloudflare), s3 (aws), gcp(google cloud)
## LOCAL UPLOADS
UPLOAD_DIR=uploads # Directory for local uploads
## CLOUDFLARE R2 STORAGE
CLOUDFLARE_R2_ENDPOINT=https://<your-account-id>.r2.cloudflarestorage.com
CLOUDFLARE_R2_DEV_URL=<your-r2-dev-subdomain-public-url>
CLOUDFLARE_R2_ACCESS_KEY=<your-access-key-id>
CLOUDFLARE_R2_SECRET_KEY=<your-secret-access-key>
CLOUDFLARE_R2_BUCKET=<your-bucket-name>
## AWS S3 STORAGE
AWS_REGION=us-west-2 # Replace with your actual region
AWS_ACCESS_KEY_ID=your-access-key-id # Replace with your actual access key ID
AWS_SECRET_ACCESS_KEY=your-secret-access-key # Replace with your actual secret access key
AWS_BUCKET_NAME=your-s3-bucket-name # Replace with your actual bucket name
GCP_PROJECT_ID=your-gcp-project-id
GCP_KEY_FILE=path/to/your/service-account-key.json
GCP_BUCKET_NAME=your-gcs-bucket-name
npx prisma migrate dev
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
Make sure you change the email for testing in should be return 201 when request is valid and success register at user.spec.ts
# unit tests (empty record in db)
$ npm run test
# have record in db (run partial)
$ npm run test -- user.spec.ts
$ npm run test -- contact.spec.ts
$ npm run test -- address.spec.ts
More simple shortcut to use in windows :D
run.bat dev|test|build|lint|prod
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
npm install -g mau
mau deploy
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
Check out a few resources that may come in handy when working with NestJS:
- Visit the NestJS Documentation to learn more about the framework.
- For questions and support, please visit our Discord channel.
- To dive deeper and get more hands-on experience, check out our official video courses.
- Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
- Need help with your project (part-time to full-time)? Check out our official enterprise support.
- To stay in the loop and get updates, follow us on X and LinkedIn.
- Looking for a job, or have a job to offer? Check out our official Jobs board.
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.