A modern, high-performance wallpaper management API built with Node.js, Express, and PostgreSQL
Features • Tech Stack • Getting Started • API Endpoints • Environment Setup
- 🚀 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
- 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
- Clone the repository
git clone https://github.com/yourusername/wallzen-backend.git
cd wallzen-backend- Install dependencies
npm install- Set up environment variables
cp .env.example .env- Initialize the database
npx prisma migrate dev
npx prisma generate- Start the development server
npm run devGET /api/wallpapers- Get all wallpapers (paginated)GET /api/wallpapers/:id- Get wallpaper by IDGET /api/wallpapers/random- Get random wallpapersGET /api/wallpapers/search- Search wallpapersGET /api/wallpapers/filter- Filter wallpapers
GET /api/wallpapers/:id/download- Download wallpaperGET /api/wallpapers/:id/preview- Get wallpaper preview
GET /api/status- Get API statusGET /api/health- Health check endpoint
# 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"interface PaginatedResponse<T> {
data: T[];
pagination: {
currentPage: number;
totalPages: number;
totalItems: number;
itemsPerPage: number;
};
}- API: 100 requests per 15 minutes
- Downloads: 30 downloads per 15 minutes
- Search: 50 searches per 15 minutes
- Health: 10 requests per minute
src/
├── controllers/ # Request handlers
├── middleware/ # Express middleware
├── models/ # Database models
├── routes/ # API routes
├── services/ # Business logic
├── utils/ # Helper functions
└── app.ts # Application entry
MIT © [justkelvin]
Made with ❤️ by justkelvin