Skip to content

NestJS Authentication with Bcrypt, JWT, Redis, GraphQL and PostgreSQL

Notifications You must be signed in to change notification settings

yusufulusoy/nest-auth

Repository files navigation

NEST-AUTH

NestJS Authentication with Bcrypt, JWT, Redis, GraphQL and PostgreSQL

license last-commit repo-top-language repo-language-count

Developed with the software and tools below.

Prettier GraphQL YAML Jest ESLint TypeScript tsnode JSON


πŸ”— Quick Links


πŸ“ Overview

Nest-auth is a cutting-edge authentication solution designed for modern web applications. Built on top of the powerful NestJS framework, it leverages the best practices in security and software design patterns to provide a comprehensive, out-of-the-box authentication system. This project aims to simplify the integration of authentication mechanisms into your applications, allowing developers to focus more on core features rather than the complexities of secure user authentication.

At its core, nest-auth incorporates a variety of security features such as JWT-based stateless authentication, social login strategies, and role-based access control, making it a versatile choice for any project. Whether you're building a small hobby project or a large-scale enterprise application, nest-auth offers the scalability and flexibility needed to meet your requirements.

Designed with developer experience in mind, nest-auth is fully documented and comes with a suite of examples to get you started quickly. Its modular architecture and the use of TypeScript make it easy to extend and maintain, ensuring that your authentication layer remains robust and up-to-date with the latest security standards.

Join the growing community of developers who trust nest-auth for their authentication needs and take the first step towards securing your application today.

πŸ“¦ Features

  • Comprehensive Authentication System: Utilizes a robust authentication system designed to secure your application, including guards and decorators for fine-grained access control.
  • GraphQL Integration: Offers full support for GraphQL, enabling you to build flexible and efficient APIs for your applications.
  • Docker Support: Includes a docker-compose.yml file for easy containerization and deployment, ensuring your application is ready for production environments.
  • TypeScript Support: Fully written in TypeScript, providing strong typing and modern JavaScript features for a more maintainable codebase.
  • Configurable Environment: Comes with a customizable configuration setup (app.config.ts and auth.config.ts), allowing for easy adjustments to meet your project's needs.
  • Unit Testing Ready: Equipped with Jest configurations for both unit and integration tests (auth.service.spec.ts and auth.resolver.spec.ts), ensuring your code is reliable and bug-free.
  • ESLint and Prettier Integration: Pre-configured with ESLint and Prettier for consistent code formatting and linting, helping maintain code quality.
  • Modular Structure: Features a modular repository structure, making it easy to navigate and scale your application as it grows.
  • PNPM Package Management: Utilizes PNPM for efficient and fast package management, reducing node_modules size and installation time.

πŸ“‚ Repository Structure

└── nest-auth/
    β”œβ”€β”€ docker-compose.yml
    β”œβ”€β”€ nest-cli.json
    β”œβ”€β”€ package.json
    β”œβ”€β”€ pnpm-lock.yaml
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ app.config.ts
    β”‚   β”œβ”€β”€ app.module.ts
    β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   β”œβ”€β”€ auth.config.ts
    β”‚   β”‚   β”œβ”€β”€ auth.guard.ts
    β”‚   β”‚   β”œβ”€β”€ auth.module.ts
    β”‚   β”‚   β”œβ”€β”€ auth.resolver.spec.ts
    β”‚   β”‚   β”œβ”€β”€ auth.resolver.ts
    β”‚   β”‚   β”œβ”€β”€ auth.service.spec.ts
    β”‚   β”‚   β”œβ”€β”€ auth.service.ts
    β”‚   β”‚   β”œβ”€β”€ decorators
    β”‚   β”‚   β”‚   β”œβ”€β”€ active-auth.decorator.ts
    β”‚   β”‚   β”‚   └── public.decorator.ts
    β”‚   β”‚   β”œβ”€β”€ dto
    β”‚   β”‚   β”‚   β”œβ”€β”€ refresh-token.input.ts
    β”‚   β”‚   β”‚   β”œβ”€β”€ signin.input.ts
    β”‚   β”‚   β”‚   └── signup.input.ts
    β”‚   β”‚   β”œβ”€β”€ entities
    β”‚   β”‚   β”‚   └── auth.entity.ts
    β”‚   β”‚   └── interfaces
    β”‚   β”‚       β”œβ”€β”€ payload.interface.ts
    β”‚   β”‚       └── token.interface.ts
    β”‚   β”œβ”€β”€ core
    β”‚   β”‚   β”œβ”€β”€ config
    β”‚   β”‚   β”‚   β”œβ”€β”€ config.enum.ts
    β”‚   β”‚   β”‚   β”œβ”€β”€ config.interface.ts
    β”‚   β”‚   β”‚   β”œβ”€β”€ config.module.ts
    β”‚   β”‚   β”‚   └── config.validation.ts
    β”‚   β”‚   β”œβ”€β”€ database
    β”‚   β”‚   β”‚   β”œβ”€β”€ database.config.ts
    β”‚   β”‚   β”‚   └── database.module.ts
    β”‚   β”‚   β”œβ”€β”€ graphql
    β”‚   β”‚   β”‚   β”œβ”€β”€ graphql.config.ts
    β”‚   β”‚   β”‚   └── graphql.module.ts
    β”‚   β”‚   └── redis
    β”‚   β”‚       β”œβ”€β”€ redis.config.ts
    β”‚   β”‚       β”œβ”€β”€ redis.constants.ts
    β”‚   β”‚       β”œβ”€β”€ redis.module.ts
    β”‚   β”‚       β”œβ”€β”€ redis.service.spec.ts
    β”‚   β”‚       └── redis.service.ts
    β”‚   β”œβ”€β”€ main.ts
    β”‚   β”œβ”€β”€ schema.gql
    β”‚   └── users
    β”‚       β”œβ”€β”€ dto
    β”‚       β”‚   └── update-user.input.ts
    β”‚       β”œβ”€β”€ entities
    β”‚       β”‚   └── user.entity.ts
    β”‚       β”œβ”€β”€ password
    β”‚       β”‚   β”œβ”€β”€ password.service.spec.ts
    β”‚       β”‚   └── password.service.ts
    β”‚       β”œβ”€β”€ users.module.ts
    β”‚       β”œβ”€β”€ users.resolver.spec.ts
    β”‚       β”œβ”€β”€ users.resolver.ts
    β”‚       β”œβ”€β”€ users.service.spec.ts
    β”‚       └── users.service.ts
    β”œβ”€β”€ test
    β”‚   β”œβ”€β”€ app.e2e-spec.ts
    β”‚   └── jest-e2e.json
    β”œβ”€β”€ tsconfig.build.json
    └── tsconfig.json

🧩 Modules

.
File Summary
docker-compose.yml β–Ί INSERT-TEXT-HERE
tsconfig.build.json β–Ί INSERT-TEXT-HERE
tsconfig.json β–Ί INSERT-TEXT-HERE
package.json β–Ί INSERT-TEXT-HERE
nest-cli.json β–Ί INSERT-TEXT-HERE
pnpm-lock.yaml β–Ί INSERT-TEXT-HERE
test
File Summary
app.e2e-spec.ts β–Ί INSERT-TEXT-HERE
jest-e2e.json β–Ί INSERT-TEXT-HERE
src
File Summary
app.config.ts β–Ί INSERT-TEXT-HERE
schema.gql β–Ί INSERT-TEXT-HERE
app.module.ts β–Ί INSERT-TEXT-HERE
main.ts β–Ί INSERT-TEXT-HERE
src.users
File Summary
users.service.ts β–Ί INSERT-TEXT-HERE
users.module.ts β–Ί INSERT-TEXT-HERE
users.resolver.spec.ts β–Ί INSERT-TEXT-HERE
users.service.spec.ts β–Ί INSERT-TEXT-HERE
users.resolver.ts β–Ί INSERT-TEXT-HERE
src.users.password
File Summary
password.service.ts β–Ί INSERT-TEXT-HERE
password.service.spec.ts β–Ί INSERT-TEXT-HERE
src.users.entities
File Summary
user.entity.ts β–Ί INSERT-TEXT-HERE
src.users.dto
File Summary
update-user.input.ts β–Ί INSERT-TEXT-HERE
src.core.graphql
File Summary
graphql.module.ts β–Ί INSERT-TEXT-HERE
graphql.config.ts β–Ί INSERT-TEXT-HERE
src.core.redis
File Summary
redis.constants.ts β–Ί INSERT-TEXT-HERE
redis.service.spec.ts β–Ί INSERT-TEXT-HERE
redis.service.ts β–Ί INSERT-TEXT-HERE
redis.config.ts β–Ί INSERT-TEXT-HERE
redis.module.ts β–Ί INSERT-TEXT-HERE
src.core.database
File Summary
database.module.ts β–Ί INSERT-TEXT-HERE
database.config.ts β–Ί INSERT-TEXT-HERE
src.core.config
File Summary
config.validation.ts β–Ί INSERT-TEXT-HERE
config.interface.ts β–Ί INSERT-TEXT-HERE
config.enum.ts β–Ί INSERT-TEXT-HERE
config.module.ts β–Ί INSERT-TEXT-HERE
src.auth
File Summary
auth.module.ts β–Ί INSERT-TEXT-HERE
auth.resolver.spec.ts β–Ί INSERT-TEXT-HERE
auth.config.ts β–Ί INSERT-TEXT-HERE
auth.guard.ts β–Ί INSERT-TEXT-HERE
auth.service.spec.ts β–Ί INSERT-TEXT-HERE
auth.resolver.ts β–Ί INSERT-TEXT-HERE
auth.service.ts β–Ί INSERT-TEXT-HERE
src.auth.entities
File Summary
auth.entity.ts β–Ί INSERT-TEXT-HERE
src.auth.interfaces
File Summary
payload.interface.ts β–Ί INSERT-TEXT-HERE
token.interface.ts β–Ί INSERT-TEXT-HERE
src.auth.dto
File Summary
signin.input.ts β–Ί INSERT-TEXT-HERE
signup.input.ts β–Ί INSERT-TEXT-HERE
refresh-token.input.ts β–Ί INSERT-TEXT-HERE
src.auth.decorators
File Summary
[pu## πŸ›  Project Roadmap
  • β–Ί INSERT-TASK-1
  • β–Ί INSERT-TASK-2
  • β–Ί ...

πŸ“¦ Features

  • Comprehensive Authentication System: Utilizes a robust authentication system designed to secure your application, including guards and decorators for fine-grained access control.
  • GraphQL Integration: Offers full support for GraphQL, enabling you to build flexible and efficient APIs for your applications.
  • Docker Support: Includes a docker-compose.yml file for easy containerization and deployment, ensuring your application is ready for production environments.
  • TypeScript Support: Fully written in TypeScript, providing strong typing and modern JavaScript features for a more maintainable codebase.
  • Configurable Environment: Comes with a customizable configuration setup (app.config.ts and auth.config.ts), allowing for easy adjustments to meet your project's needs.
  • Unit Testing Ready: Equipped with Jest configurations for both unit and integration tests (auth.service.spec.ts and auth.resolver.spec.ts), ensuring your code is reliable and bug-free.
  • ESLint and Prettier Integration: Pre-configured with ESLint and Prettier for consistent code formatting and linting, helping maintain code quality.
  • Modular Structure: Features a modular repository structure, making it easy to navigate and scale your application as it grows.
  • PNPM Package Management: Utilizes PNPM for efficient and fast package management, reducing node_modules size and installation time.orators/public.decorator.ts) | β–Ί INSERT-TEXT-HERE | | active-auth.decorator.ts | β–Ί INSERT-TEXT-HERE |

πŸš€ Getting Started

βš™οΈ Installation

  1. Clone the nest-auth repository:
git clone https://github.com/yusufulusoy/nest-auth
  1. Change to the project directory:
cd nest-auth
  1. Install the dependencies:
pnpm install

πŸ€– Running nest-auth

Use the following command to run nest-auth:

pnpm run build && node dist/main.js

πŸ§ͺ Tests

To execute tests, run:

pnpm test

🀝 Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your GitHub account.
  2. Clone Locally: Clone the forked repository to your local machine using a Git client.
    git clone https://github.com/yusufulusoy/nest-auth
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to GitHub: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

Once your PR is reviewed and approved, it will be merged into the main branch.


πŸ“„ License

This project is protected under the MIT License.


πŸ‘ Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

Return


About

NestJS Authentication with Bcrypt, JWT, Redis, GraphQL and PostgreSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published