Skip to content

hode2002/image-enhancer-server

Repository files navigation

Nest Logo

NestJS Image Server

Image processing server with robust logging and cloud integration

TypeScript NestJS PostgreSQL Prisma Docker AWS Cloudinary Clerk Swagger

🚀 Quick Start

# Start development server
pnpm run start:dev

✨ Features

Feature Description
🖼️ Image Processing Advanced image management and processing capabilities
🔒 Authentication Secure auth with Clerk and Google OAuth
📝 Logging Winston-based logging with file rotation
🐳 Containerization Docker support for easy deployment
🗄️ Database PostgreSQL with Prisma ORM
🔄 CI/CD Automated deployment with GitHub Actions
🚀 Cloud AWS EC2 deployment support
📚 API Documentation Interactive Swagger UI documentation

⚙️ Configuration

Environment Setup

# Application
PORT=3001
ALLOWED_ORIGINS=["http://localhost:3001"]
FRONTEND_URL=http://localhost:3001

# Database
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
DIRECT_URL="postgresql://user:password@localhost:5432/dbname"

# Authentication
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
CLERK_PUBLISHABLE_KEY=your_clerk_key
CLERK_SECRET_KEY=your_clerk_secret

# Image Storage
CLOUDINARY_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_key
CLOUDINARY_API_SECRET=your_cloudinary_secret

# File Upload
MAX_FILE_SIZE=5242880
ALLOWED_MIME_TYPES=image/jpeg,image/png,image/gif,image/webp,image/avif

📚 API Documentation

The API documentation is available through Swagger UI at /api/docs when the server is running.

Swagger UI Features

  • Interactive API documentation
  • Try-it-out functionality
  • Request/response examples
  • Bearer token authentication
  • Schema validation
  • API versioning

📝 Logging

The application implements a comprehensive logging system using Winston:

  • Console Output: Colored, formatted logs
  • File Logs:
    • logs/error.log: Error-specific logs
    • logs/combined.log: All application logs
  • Features:
    • Request/response logging
    • Error stack traces

Configure log level via environment:

LOG_LEVEL=debug  # Options: error, warn, info, debug, verbose

🚀 Deployment

GitHub Actions Setup

Required secrets:

  • DOCKER_USERNAME
  • DOCKER_TOKEN
  • EC2_HOST
  • EC2_USER
  • EC2_SSH_KEY

Deploy by pushing to main branch.