NestJS Auth REST API Template
with JWT Authentication.
This NestJS Auth REST API Template
is designed to jumpstart your development process with a robust user authentication system and protected routes. Built using Nest.js, Prisma, and Postgres, this template provides essential features such as user registration, login, JWT authentication, and a CRUD API for managing users. The API is also fully documented using Swagger for easy integration and understanding.
-
User Registration: Allow users to create new accounts securely.
-
Login and Authentication: Authenticate users using JWT tokens for secure access to protected routes.
-
Protected Routes: Implement role-based access control to ensure that only authorized users can access specific endpoints.
-
User CRUD Operations: Simplify user management with CRUD operations for creating, reading, updating, and deleting user data.
-
Swagger Documentation: Comprehensive documentation with Swagger UI for easy API exploration and integration.
-
Nest.js: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
-
Prisma: Modern database toolkit for Node.js and TypeScript, providing type-safe database access and migrations.
-
Postgres: Powerful open-source relational database system for storing and managing data securely.
-
JWT: JSON Web Tokens for secure authentication and authorization.
npm install
See the .env.template
file for more information
Docker desktop must be open
docker compose up -d
npx prisma migrate dev --name "Initial Schema"
Two users will be created. The first one as admin [email protected]
and the second one as user [email protected]
, same password for both 123456
.
npm run seed
npm run dev
The API documentation is generated using Swagger, a powerful yet easy-to-use suite of API developer tools for teams and individuals, enabling development across the entire API lifecycle, from design and documentation, to test and deployment.
You can access a demo version of the Swagger documentation for this APY at the following link: NestJS Auth REST API Template Swagger Documentation
You can also access the Swagger documentation With the REST API running locally by visiting http://localhost:3000/api.
In addition to the Swagger documentation, we also provide a comprehensive Postman documentation for the NestJS Auth REST API
.
Postman documentation collection is available at NestJS Auth REST API Template Postman Documentation
Please note that you'll need to have Postman installed on your machine to import and use the collection.
Our Postman documentation includes a collection of about 160 tests that cover all the API endpoints. These tests serve as a valuable resource for understanding the expected request and response patterns and for validating the functionality of the API. This is the report for the last test run with 3 iterations: NestJS Auth REST API Template PostgreSQL Prisma Tests
You can access to the test collection at NestJS Auth REST API Template Postman Test Collection
Contributions are welcome! Feel free to fork this repository, make improvements, and submit pull requests to enhance the functionality or add new features.
This project is licensed under the MIT License - see the LICENSE file for details.
For any issues or questions related to this API template, please open an issue on GitHub.