A simple, naive implementation of a Micropub media endpoint.
The project has the following directory structure:
├── src
| ├── app.mjs
| ├── routes
| | └── upload.mjs
| ├── utils
| | └── fileHandler.mjs
| └── middleware
| └── auth.mjs
├── temp
├── package.json
└── README.md
To run the project, follow these steps:
- Clone the repository.
- Navigate to the project directory:
cd /home/chris/src/mage.chrismcleod.dev/
. - Install the dependencies:
npm install
. - Start the server:
npm start
.
Once the server is running, you can send a POST request to the /micropub/media
endpoint with a JSON payload and an image file. The request should include a Bearer token for authentication.
Example cURL command:
curl -X POST \
-H "Authorization: Bearer <your_token>" \
-H "Content-Type: multipart/form-data" \
-F "[email protected];type=image/jpeg" \
-i \
http://localhost:3000/micropub/media
Replace <your_token>
with your actual Bearer token, and image.jpg
with the path to your image file.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please fork the repository and submit a pull request.
If you have any questions or suggestions, feel free to reach out to the project maintainers.
This project was inspired by the need for a simple Node.js REST API that handles JSON + image file uploads and authentication using Bearer tokens.