Skip to content

Latest commit

 

History

History
147 lines (116 loc) · 3.13 KB

File metadata and controls

147 lines (116 loc) · 3.13 KB

🖼️ Wallzen Backend

A modern, high-performance wallpaper management API built with Node.js, Express, and PostgreSQL

FeaturesTech StackGetting StartedAPI EndpointsEnvironment Setup


✨ Features

  • 🚀 High-performance image serving
  • 🔒 Rate limiting for API protection
  • 📱 Responsive image resizing
  • 🔍 Advanced search capabilities
  • 🏷️ Tag-based categorization
  • 🎨 Color extraction and filtering
  • 📊 Download and view statistics
  • 🗃️ PostgreSQL database with Prisma ORM

🛠️ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: PostgreSQL
  • ORM: Prisma
  • Image Processing: Sharp
  • File Storage: Local filesystem
  • API Security: Express Rate Limit
  • Documentation: Swagger/OpenAPI

🚀 Getting Started

  1. Clone the repository
git clone https://github.com/yourusername/wallzen-backend.git
cd wallzen-backend
  1. Install dependencies
npm install
  1. Set up environment variables
cp .env.example .env
  1. Initialize the database
npx prisma migrate dev
npx prisma generate
  1. Start the development server
npm run dev

📡 API Endpoints

Wallpapers

  • GET /api/wallpapers - Get all wallpapers (paginated)
  • GET /api/wallpapers/:id - Get wallpaper by ID
  • GET /api/wallpapers/random - Get random wallpapers
  • GET /api/wallpapers/search - Search wallpapers
  • GET /api/wallpapers/filter - Filter wallpapers

Downloads

  • GET /api/wallpapers/:id/download - Download wallpaper
  • GET /api/wallpapers/:id/preview - Get wallpaper preview

Statistics

  • GET /api/status - Get API status
  • GET /api/health - Health check endpoint

🔧 Environment Variables

# Server Configuration
PORT=3001
NODE_ENV=development

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

# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
API_RATE_LIMIT=100
DOWNLOAD_RATE_LIMIT=30
SEARCH_RATE_LIMIT=50

# File Storage
UPLOAD_DIR="./uploads"
PREVIEWS_DIR="./previews"

📊 API Response Format

interface PaginatedResponse<T> {
  data: T[];
  pagination: {
    currentPage: number;
    totalPages: number;
    totalItems: number;
    itemsPerPage: number;
  };
}

🔒 Rate Limiting

  • API: 100 requests per 15 minutes
  • Downloads: 30 downloads per 15 minutes
  • Search: 50 searches per 15 minutes
  • Health: 10 requests per minute

📦 Project Structure

src/
├── controllers/    # Request handlers
├── middleware/     # Express middleware
├── models/        # Database models
├── routes/        # API routes
├── services/      # Business logic
├── utils/         # Helper functions
└── app.ts         # Application entry

📝 License

MIT © [justkelvin]


Made with ❤️ by justkelvin