Node.js REST API for authenticated image upload, processing, and metadata extraction. Integrates with Azure Cosmos DB, Bunny Storage, and (optionally) Azure Blob Storage. Implements Micropub media endpoint and related image/photo APIs.
├── src
│ ├── app.mjs # Express app setup, middleware, routes
│ ├── routes/ # API endpoints (micropub, images, photos, etc.)
│ ├── utils/ # Core utilities (storage, DB, image processing, logging)
│ ├── middleware/auth.mjs # Bearer token authentication
│ └── types/ # Type definitions
├── saved/ # Saved images (temporary)
├── temp/ # Multer temp uploads
├── package.json
└── README.md
- Clone the repository.
- Navigate to the project directory:
cd ~/Projects/apis/mage.chrismcleod.dev/ - Install dependencies:
npm install - Set up environment variables in a
.envfile (see below) - Start the server:
npm start
COSMOS_CONNECTION_STRING,COSMOS_DATABASE,COSMOS_CONTAINER(Azure Cosmos DB)STORAGE_ACCOUNT,STORAGE_KEY,CONTAINER_NAME(Azure Blob Storage)BUNNY_CONTAINER,BUNNY_ACCESS_KEY,BUNNY_REGION(Bunny Storage)BASE_URL,UPLOAD_PATH,SAVE_PATH,TEMP_PATH(paths)OPENAI_API_KEY(OpenAI API integration)
All endpoints except /api-docs, /photos, and / require a Bearer token.
POST /micropub/media— Upload image (multipart/form-data, Bearer token required)GET /images/list— List all image metadataGET /images/image/:index— Get image metadata by indexPOST /photos/webhook— Netlify webhook for photo feed updatesGET /api-docs— Swagger/OpenAPI documentation
curl -X POST \
-H "Authorization: Bearer <your_token>" \
-H "Content-Type: multipart/form-data" \
-F "file=@image.jpg;type=image/jpeg" \
http://localhost:3000/micropub/mediaReplace <your_token> with your Bearer token, and image.jpg with your image file path.
- Uploaded images are saved to
saved/(temp), then uploaded to Bunny Storage (default) and optionally Azure Blob Storage. - Metadata (including EXIF/PNG info, resized formats) is stored in Azure Cosmos DB.
- All image metadata objects follow the
ImageObjecttypedef insrc/utils/imageList.mjs. - Logging via Winston (
src/utils/logger.mjs).
- Use ES modules (
.mjs), async/await, and JSDoc for type hints. - Extend endpoints by following patterns in
src/routes/and attaching required clients toreqin middleware. - For new storage integrations, follow the structure in
azureStorage.mjsandbunnyStorage.mjs.
MIT License. See LICENSE.
Fork the repository and submit a pull request.
Open an issue or reach out to the maintainers.
Inspired by the need for a simple Node.js REST API for authenticated image uploads and metadata extraction.