This is an example for setting up a serverless micropub endpoint. It has been tested and is actively used to publish posts to my site benji.dog by committing code to my repo benjifs/benji using benjifs/micropub and benjifs/github-store.
Clicking the "Deploy to Netlify" button will fork this repository and create a new Netlify site which, after configuration, can be used with any Micropub Client to add content to your site.
When setting this project up on Netlify, you should be asked to configure the following environment variables:
| Environment Variable | Description |
|---|---|
ME |
Your website url (https://example.com/) |
TOKEN_ENDPOINT |
Endpoint to validate token (https://tokens.indieauth.com/token) |
GITHUB_TOKEN |
GitHub Personal access token |
GITHUB_USER |
Username for repo where posts are added to |
GITHUB_REPO |
Name of repo where posts are added to |
By default, posts will be created under /src/${postType}/${slug}.md where
postType matches one of the post types supported by the
endpoint. Files will be uploaded to the media endpoint under /uploads. You can
change this behavior by changing the value of contentDir and mediaDir in /netlify/config.js.
For additional configuration options, checkout the main project repo.
Send a application/json, x-www-form-urlencoded, or multipart/form-data request
to create a post. See 3.6.3 Request.
Can also handle update, delete, and undelete actions.
201on success with aLocationheader for the URL of the created post.400an error occurred with approriate error message.401or403if unauthorized or invalid token was provided.
q=config: Get micropub configuration. See 3.7.1 Configuration.q=media-endpoint: Get media endpoint if configured. See 3.6.1 Discoveryq=post-types: Get supported post types. See discussion about proposed extension.q=syndicate-to: Get a list of supported syndication targets. See 3.7.3 Syndication Targetsq=source&url=: Get properties for post inurl. Optionally can also addproperties=to only get those properties as the response. See 3.7.2 Source Content.
Send a multipart/form-data request to upload a file. See 3.6.3 Request.
201on success with aLocationheader for the URL of the uploaded item.400if no file was uploaded with approriate error message.401or403if unauthorized or invalid token was provided.
q=source: Get list of most recently uploaded files. Optionally can useoffsetandlimitto implement pagination. See discussion about proposed extension.
The current supported post types are:
You can modify which post types are supported by setting the value for post-types
in /netlify/config.js.
Note: If a post does not fit under a specific type, it will default to be of type
note.
MEshould have a trailing slash- If you make a change to the environment variables in Netlify, you must redeploy otherwise it will continue using the old variables.