grantcodes / future-micropub-endpoint

Building a micropub endpoint middleware for the future 🔮
9 stars 0 forks source link

Package proposal: Form-encoded request to mf2 #6

Open paulrobertlloyd opened 5 years ago

paulrobertlloyd commented 5 years ago

In the spirit of creating small un-opinionated packages that do one thing well (rather than attempt to build a single monolith package), a candidate for broader collaboration between node-based projects would be one that rewrites Microformats parameters provided in a form-encoded POST request and converts them to mf2.

Prior art

Micropub Express / IndieKit

IndieKit performs this function in code that can be found here. This was adapted from code found in Micropub Express by @voxpelli which can be found here.

Postr

Postr performs this function in an Express middleware function that can be found here.

Final thoughts

For me this was one of the trickiest building blocks to understand and build adapt, and like post type discovery, prone to errors. It’d be nice to collaborate on a common package that accounts for all the possible form-encoded requests that may need to be converted into mf2.

@indieweb/form-encoded-to-mf2 anyone?

grantcodes commented 5 years ago

So for this one, while I agree it should be somewhat independent, I don't think it should be its own module, mainly because its only use case (that I can think of) is inside a micropub endpoint. And I think our goal with a fill micropub endpoint middleware should be that everyone would want to use the full package, not just form encoded -> mf2 object conversion

In my opinion it should be a middleware within a micropub endpoint middleware, that could be used standalone if someone really, really wanted to.

Having said that it is a good starting point that could be developed and tested separately from a micropub endpoint.

voxpelli commented 5 years ago

For me this was one of the trickiest building blocks to understand and build [...] prone to errors.

A first step here could be to make a test suite that one can add to test an implementation of this, taking inspiration from eg:

voxpelli commented 5 years ago

our goal with a fill micropub endpoint middleware should be that everyone would want to use the full package

As I wrote in #1, what our goal in my opinion should be, and I get the feeling that @paulrobertlloyd agrees, to help one another in building our endpoints.

Collaborating in removing the need for implementing ones own error prone and boring methods like this one + adapting similar API:s to enhance the ecosystem and allow for an extension of one endpoint to also be used with another one.

So anyone can eg. add media functionality that works with multiple endpoint implementations, thus making it less of an effort to maintain any single project within this space.

paulrobertlloyd commented 5 years ago

I get the feeling that @paulrobertlloyd agrees, to help one another in building our endpoints.

Correct! I don’t think the requirement for a package should be “can it be used for different IndieWeb projects (Micropub, Microsub, Webmention)” necessarily, more “can authors of different Micropub projects drop in a package to address the dull/boring/complex/error-prone parts of the spec”.