npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@benjifs/micropub

v2.0.1

Published

serverless micropub endpoint

Readme

micropub

This project allows you to create a serverless Micropub and media endpoint which can add files to your static sites' repository. After setup, you can use any Micropub Client to add posts to your site. Tested with Eleventy and Hugo.

To run this, checkout the serverless-micropub repository which provides a basic working example to get micropub setup using Netlify functions.

Install

npm install @benjifs/micropub

Usage

import MicropubEndpoint from '@benjifs/micropub'
import GitHubStore from '@benjifs/github-store'

const {
	ME, TOKEN_ENDPOINT,
	GITHUB_TOKEN, GITHUB_USER, GITHUB_REPO,
} = process.env

export const micropub = new MicropubEndpoint({
	store: new GitHubStore({
		token: GITHUB_TOKEN,
		user: GITHUB_USER,
		repo: GITHUB_REPO,
	}),
	me: ME,
	tokenEndpoint: TOKEN_ENDPOINT,
})

export default async (req) => micropub.micropubHandler(req)

Configuration

The following options can be added when initializing this project:

me (Required)

URL for your site with trailing slash

me: 'https://example.com/'

tokenEndpoint (Required)

Token endpoint to verify the access token submitted.

tokenEndpoint: 'https://auth.example.com/token'

contentDir

The main directory where your posts will be added to.

contentDir: 'src' // Default value

mediaDir

The directory where your media endpoint will add files to.

mediaDir: 'uploads' // Default value

translateProps

11ty uses different naming for properties (eg. name -> title, category -> tags). Settings this value to true (default) makes sure that these properties are translated between what 11ty and the expected valid microformats.

translateProps: true // Default value

formatSlug

You can configure if you want your posts of a specific type to go into a different directory. For example, you can configure all posts regardless of type to go into the same directory or all posts of type note and reply to go into a notes directory.

formatSlug: (type, slug) => `${type}/${slug}` // Default value

formatFilename

Use if you do not use markdown as your file types.

formatFilename: (dir, slug) => `${dir}/${slug}.md` // Default value

mediaFilename

File name for uploaded files. Can be useful if you want the filenames to share a common prefix, or to use a date format other than milliseconds.

mediaFilename: (mediaDir, filename) => `${mediaDir}/${timestamp}_${filename}` // Default value

config.media-endpoint

URL for your media endpoint. If not configured, Micropub clients will not know the endpoint exists.

See 3.6.1 Discovery.

config: {
	...
	'media-endpoint': 'https://micropub.example.com/media',
	...
}

config.syndicate-to

Syndicate target options.

See 3.7.3 Syndication Targets.

config: {
	...
	'syndicate-to': [
		{ uid: 'https://fed.brid.gy/', name: 'w/ Bridgy Fed', checked: true },
	],
	...
}

config.post-types

Define supported post types for a micropub client to show.

See discussion about proposed extension.

config: {
	...
	'post-types': [ // Default values
			{ type: 'note', name: 'Note' },
			{ type: 'photo', name: 'Photo' },
			{ type: 'reply', name: 'Reply' },
			{ type: 'bookmark', name: 'Bookmark' },
			{ type: 'like', name: 'Like' },
			{ type: 'article', name: 'Article' },
			{ type: 'rsvp', name: 'RSVP' },
			{ type: 'repost', name: 'Repost' },
			{ type: 'watch', name: 'Watch' },
			{ type: 'read', name: 'Read' },
			{ type: 'listen', name: 'Listen' },
			{ type: 'game', name: 'Game' },
		],
	...
}

Post Types

The current supported post types are:

Note: If a post does not fit under a specific type, it will default to be of type note.

Scopes

  • create - allows the client to create posts on behalf of the user
  • update - allows the client to edit existing posts
  • delete - allows the client to delete posts
  • undelete - allows the client to undelete posts
  • media - allows the client to upload files to the media endpoint

Troubleshooting

  • ME should have a trailing slash

References