diff --git a/.env.example b/.env.example index 7112d5d..a387750 100644 --- a/.env.example +++ b/.env.example @@ -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 @@ -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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f88dc42 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026-present Bijin Krishn + +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. diff --git a/README.md b/README.md index d30c946..abf153e 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,32 @@ -

- Nest Logo -

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

A progressive Node.js framework for building efficient and scalable server-side applications.

-

-NPM Version -Package License -NPM Downloads -CircleCI -Discord -Backers on Open Collective -Sponsors on Open Collective - Donate us - Support us - Follow us on Twitter -

- +# 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 ``` @@ -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 @@ -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). diff --git a/package.json b/package.json index b015e03..127466d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" ]