A simple REST API that saves any file sent to it.
- Upload single or multiple files
- Capture POST request metadata (URL, headers, body, query params, etc.)
- List all uploaded files and captured metadata
- Configurable file size limits
- Health check endpoint
- Production-ready error handling
- Install dependencies:
npm install- Start the server:
npm start- The API will be available at
http://localhost:3000
Upload a single file:
curl -X POST -F "file=@/path/to/your/file.txt" http://localhost:3000/uploadUpload multiple files:
curl -X POST -F "files=@file1.txt" -F "files=@file2.txt" http://localhost:3000/upload/multipleCapture request metadata (no file needed):
# Send JSON data
curl -X POST http://localhost:3000/capture \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "john@example.com"}'
# Send form data
curl -X POST http://localhost:3000/capture \
-d "name=John&email=john@example.com"
# With query parameters
curl -X POST "http://localhost:3000/capture?user=123&source=mobile" \
-d "action=login"List uploaded files:
curl http://localhost:3000/filesList captured metadata:
curl http://localhost:3000/metadataView specific metadata file:
curl http://localhost:3000/metadata/request-1234567890.jsonPOST /upload- Upload a single file (field name:file)POST /upload/multiple- Upload multiple files (field name:files, max 10)GET /files- List all uploaded files
POST /capture- Capture and save all request metadata (headers, body, query params, URL, etc.)GET /metadata- List all captured metadata filesGET /metadata/:filename- View specific metadata file
GET /health- Health check
The /capture endpoint extracts and saves:
- Timestamp and ISO date
- HTTP method and URL
- Query parameters
- Request headers
- Request body (JSON, form data, etc.)
- Client IP address
- Protocol and security info
- Cookies (if present)
Create a .env file (optional):
PORT=3000
UPLOAD_DIR=./uploads
METADATA_DIR=./metadata
MAX_FILE_SIZE=104857600
PORT: Server port (default: 3000)UPLOAD_DIR: Directory to save files (default: ./uploads)METADATA_DIR: Directory to save captured request metadata (default: ./metadata)MAX_FILE_SIZE: Max file size in bytes (default: 100MB)
- Push your code to GitHub
- Go to render.com and sign up
- Click "New" → "Web Service"
- Connect your GitHub repository
- Configure:
- Build Command:
npm install - Start Command:
npm start - Add environment variables if needed
- Build Command:
- Click "Create Web Service"
Your API will be live at https://your-service.onrender.com
- Push code to GitHub
- Go to railway.app
- Click "Start a New Project" → "Deploy from GitHub repo"
- Select your repository
- Railway auto-detects Node.js and deploys
- Install Fly CLI:
brew install flyctl(macOS) - Login:
flyctl auth login - Launch app:
flyctl launch - Deploy:
flyctl deploy
- Push code to GitHub
- Go to DigitalOcean → App Platform
- Create new app from GitHub
- Configure build and run commands
- Deploy
- Install Heroku CLI
- Login:
heroku login - Create app:
heroku create - Deploy:
git push heroku main
- SSH into your server
- Install Node.js:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - - Clone your repo:
git clone <your-repo> - Install dependencies:
npm install - Install PM2:
npm install -g pm2 - Start server:
pm2 start server.js - Setup nginx reverse proxy (optional)
Example nginx config:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}- Set appropriate
MAX_FILE_SIZEto prevent abuse - Implement authentication if needed
- Consider using cloud storage (AWS S3, Google Cloud Storage) for uploaded files
- Add rate limiting to prevent spam
- Set up monitoring and logging
- Use HTTPS in production
MIT