Skip to content

Repository files navigation

🚀 NestJS Prisma Authentication API

A backend API built with NestJS and Prisma, featuring a secure authentication system based on JWT, HTTP-only cookies, and user management.
The project follows a modular, scalable, and maintainable architecture, applying modern backend best practices.

📌 Features

  • 🔐 User authentication (Register / Login / Logout)
  • 🔑 JWT-based authentication (Access & Refresh Tokens)
  • 🍪 Secure authentication using HTTP-only cookies
  • 🛡️ Protected routes with NestJS Guards
  • 🗄️ Database access via Prisma ORM
  • ✅ Data validation with class-validator
  • 🔒 Password hashing using bcrypt
  • 📦 Modular NestJS architecture

🛠️ Tech Stack

  • Backend: NestJS
  • ORM: Prisma
  • Database: PostgreSQL
  • Authentication: JWT
  • Security: HTTP-only cookies, bcrypt
  • Validation: class-validator
  • Language: TypeScript

📁 Project Structure src/ ├── app.controller.ts ├── app.service.ts ├── app.module.ts ├── main.ts ├── prisma/ │ └── prisma.service.ts ├── authentification/ │ ├── authentification.module.ts │ ├── authentification.controller.ts │ ├── authentification.service.ts │ ├── authentification.guard.ts │ └── dto/ │ ├── login.dto.ts │ └── register.dto.ts

⚙️ Environment Variables

Create a .env file in the root directory: DATABASE_URL=postgresql://user:password@localhost:5432/dbname SECRET_ACCESS=your_access_token_secret SECRET_REFRESH=your_refresh_token_secret

📦 Installation

Install dependencies

npm install

Generate Prisma client

npx prisma generate

Run database migrations

npx prisma migrate dev

Start the application

npm run start:dev

About

The backend API, developed with NestJS and Prisma, integrates a secure authentication system based on JWT, HTTP-only cookies, and user management

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages