Skip to content

Enterprise-grade NestJS backend for managing developer projects, resources, secrets, and API keys with Keycloak authentication.

License

Notifications You must be signed in to change notification settings

Dev-Tech-Labs/nestjs-stack

 
 

Repository files navigation

NestJS Stack Backend API

Repository Size Last Commit Issues Forks Stars

nestapi

Enterprise-grade NestJS backend for managing developer projects, resources, secrets, and API keys with Keycloak authentication.

🛠️ Tech Stack

  • Framework: NestJS + Fastify
  • Database: PostgreSQL with Prisma ORM
  • Auth: Keycloak Integration
  • Docs: OpenAPI/Swagger
  • Testing: Jest + Supertest

🚀 Features

Authentication & Authorization

  • Keycloak integration
  • JWT token validation
  • Role-based access control
  • User registration & login
  • Token refresh support

Project Management

  • CRUD operations
  • Ownership validation
  • Soft delete functionality
  • Pagination & filtering
  • Search capabilities

Resource Management

  • Secure secrets storage
  • API keys management
  • Project-based organization
  • Resource type validation
  • Archive/restore support

🏗️ Installation

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env

# Run database migrations
npx prisma migrate dev

🚀 Running the App

# Development
npm run start:dev

# Production
npm run start:prod

🧪 Testing

# Unit tests
npm run test

# E2E tests
npm run test:e2e

# Test coverage
npm run test:cov

📚 API Documentation

Once the application is running, access the Swagger documentation at:

http://localhost:3000/api/docs

🔧 Environment Variables

# Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/neststack"

# Keycloak
KEYCLOAK_AUTH_SERVER_URL="http://localhost:8080/auth"
KEYCLOAK_REALM="realm-name"
KEYCLOAK_CLIENT_ID="client-name"
KEYCLOAK_CLIENT_SECRET="your-client-secret"

# App
PORT=3000
NODE_ENV=development

📁 Project Structure

src/
├── auth/           # Authentication & authorization
├── project/        # Project management
├── resource/       # Resource management
├── prisma/         # Database schema & migrations
├── dto/            # Data transfer objects
└── config/         # Configuration files

🧪 Test Environment

# Create test database
psql -U postgres -c "CREATE DATABASE neststack_test;"

# Run tests with test environment
NODE_ENV=test npm run test

📝 API Endpoints

Auth Routes

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout

Project Routes

  • GET /api/projects - List all projects
  • POST /api/projects - Create project
  • GET /api/projects/:id - Get project
  • PUT /api/projects/:id - Update project
  • DELETE /api/projects/:id - Delete project

Resource Routes

  • GET /api/resources - List all resources
  • POST /api/resources - Create resource
  • GET /api/resources/:id - Get resource
  • DELETE /api/resources/:id - Delete resource

👤 Author

Jawher Kallel

📄 License

This project is MIT licensed.

About

Enterprise-grade NestJS backend for managing developer projects, resources, secrets, and API keys with Keycloak authentication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.3%
  • JavaScript 2.7%