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]