Skip to content

benjifs/serverless-micropub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serverless-micropub

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.

Deploy to Netlify

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.

Setup

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.

Usage

POST /micropub

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.

Response

  • 201 on success with a Location header for the URL of the created post.
  • 400 an error occurred with approriate error message.
  • 401 or 403 if unauthorized or invalid token was provided.

GET /micropub

POST /media

Send a multipart/form-data request to upload a file. See 3.6.3 Request.

Response

  • 201 on success with a Location header for the URL of the uploaded item.
  • 400 if no file was uploaded with approriate error message.
  • 401 or 403 if unauthorized or invalid token was provided.

GET /media

Post Types

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.

Troubleshooting

  • ME should 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.

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors