This is an Image Processing Service built with Node.js, Express, TypeScript, and Mongoose. It allows users to upload, transform, and retrieve images using Cloudinary for storage. The service supports transformations such as resizing, cropping, rotating, watermarking, and applying filters.
- User Authentication
- Register and Login users
- JWT authentication for secure endpoints
- Image Upload & Management
- Upload images to Cloudinary
- Retrieve images
- List all uploaded images by the user
- Image Transformation
- Resize, Crop, Rotate, Flip, Mirror
- Add Watermarks
- Convert formats (JPEG, PNG, etc.)
- Apply filters (Grayscale, Sepia, etc.)
- Rate Limiting
- Prevent excessive API requests using a rate limiter
- Backend: Node.js, Express.js, TypeScript
- Database: MongoDB (Mongoose ORM)
- Authentication: JWT
- File Storage: Cloudinary
- Security: Rate Limiting with
express-rate-limit
- Node.js (v16 or later)
- MongoDB (local or cloud instance)
- Cloudinary Account (for image storage)
git clone https://github.com/your-repo/image-processing-service.git
cd image-processing-servicenpm installCreate a .env file in the root directory and add:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
CLOUDINARY_CLOUD_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
RATE_LIMIT_WINDOW=15
RATE_LIMIT_MAX=100npm run devThe server will start on http://localhost:5000.
POST /registerRequest Body:
{
"username": "user1",
"password": "password123"
}Response:
{
"user": { "id": "123", "username": "user1" },
"token": "your_jwt_token"
}POST /loginRequest Body: Same as Register
Response: JWT Token
POST /imagesRequest Body: Multipart form-data with image file
Response:
{
"url": "https://res.cloudinary.com/...",
"metadata": { "width": 500, "height": 500 }
}POST /images/:id/transformRequest Body:
{
"transformations": {
"resize": { "width": 300, "height": 300 },
"crop": { "width": 100, "height": 100, "x": 10, "y": 10 },
"rotate": 90,
"filters": { "grayscale": true }
}
}GET /images/:idResponse: Image metadata and URL
GET /images?page=1&limit=10To prevent excessive API requests, the service uses express-rate-limit. The default settings allow 100 requests per 15 minutes per IP address. You can modify these settings in the .env file:
RATE_LIMIT_WINDOW=15 # Time window in minutes
RATE_LIMIT_MAX=100 # Max requests per window per IPIf the rate limit is exceeded, the server will return a 429 Too Many Requests response.
This project is licensed under the MIT License.