Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
POSTGRES_USER=USER
POSTGRES_PASSWORD=PASSWORD
POSTGRES_DB=DB_NAME
# Database
# Database (postgresql)
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DB_NAME
# Redis
REDIS_URL=redis://HOST:PORT
Expand All @@ -16,6 +16,6 @@ JWT_REFRESH_EXPIRES_IN=2h
# Throttle - Rate limiting
THROTTLE_TTL=60000
THROTTLE_LIMIT=10
# Super admin data
# Super admin data (optional)
SUPER_ADMIN_EMAIL=SUPERADMIN@EXAMPLE.COM
SUPER_ADMIN_PASSWORD=PASSWORD
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026-present Bijin Krishn <https://github.com/bijink>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
89 changes: 35 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
# Authentication System

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
Production-ready authentication and authorization API for SaaS applications built with NestJS, Prisma, and PostgreSQL, featuring RBAC, JWT auth, audit logs, and secure user management.

## Project requirment

- Node ^22
- Pnpm ^10
- Docker

## Project setup

Create `.env` file in root directory and add these variables.

```bash
# need POSTGRES_DB in .env file for variable interpolation in docker-compose.yml files
POSTGRES_DB=DB_NAME

# need DATABASE_URL in .env file for prisma studio
# for dev environment:
DATABASE_URL=postgresql://USER:PASSWORD@localhost:5431/DB_NAME
# for prod environment:
# DATABASE_URL=postgresql://USER:PASSWORD@localhost:5432/DB_NAME
```

Then create `.env.development` (for dev environment) and `.env.production` (for prod environment) files in root directory. Add variables according to the example variables given in `.env.example` file.

```bash
$ pnpm install
```
Expand All @@ -35,13 +35,13 @@ $ pnpm install

```bash
# development
$ pnpm run start
$ pnpm run start:docker

# watch mode
$ pnpm run start:dev
$ pnpm run start:docker:dev

# production mode
$ pnpm run start:prod
$ pnpm run start:docker:prod
```

## Run tests
Expand All @@ -57,42 +57,23 @@ $ pnpm run test:e2e
$ pnpm run test:cov
```

## Deployment
## Development

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](https://docs.nestjs.com/deployment) for more information.
### Add new packages

If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
To add new node packages, you need to mount the local `node_modules` with the docker container `node_modules`.

First install package locally. Then run (may be twice)

```bash
$ pnpm install -g @nestjs/mau
$ mau deploy
# restart docker api dev container
$ pnpm run api:dev:restart
```

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

## Resources

Check out a few resources that may come in handy when working with NestJS:

- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).

## Support

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](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
- Author - [Bijin Krishn](https://twitter.com/bijinkrishn)

## License

Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
Authentication System is [MIT licensed](https://github.com/bijink/authentication-system/main/LICENSE).
20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@
"name": "auth-system",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"author": "Bijin Krishn",
"license": "MIT",
"scripts": {
"postinstall": "prisma generate",
"prisma:dev:deploy": "prisma migrate deploy",
"prisma:dev:seed": "prisma db seed",
"prisma:studio": "pnpm prisma studio",
"db:dev:rm": "docker compose -f docker-compose.dev.yml rm dev-db dev-redis -s -v",
"db:dev:up": "docker compose -f docker-compose.dev.yml up dev-db dev-redis -d",
"db:dev:restart": "pnpm db:dev:rm && pnpm db:dev:up && sleep 1 && pnpm prisma:dev:deploy && pnpm prisma:dev:seed",
"api:dev:restart": "docker compose -f docker-compose.dev.yml restart dev-api",
"start:docker": "docker compose -f docker-compose.dev.yml up -d",
"start:docker:dev": "docker compose -f docker-compose.dev.yml up",
"start:docker:prod": "docker compose up",
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"format": "prettier --write \"{src,test,prisma}/**/*.ts\"",
"format:check": "prettier --check \"{src,test,prisma}/**/*.ts\"",
"lint": "eslint \"{src,test,prisma}/**/*.ts\"",
"lint:fix": "eslint \"{src,test,prisma}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
Expand All @@ -32,7 +36,7 @@
"prepare": "husky"
},
"lint-staged": {
"{src,apps,libs,test,prisma}/**/*.ts": [
"{src,test,prisma}/**/*.ts": [
"prettier --write",
"eslint --fix --max-warnings=0"
]
Expand Down
Loading