mal.haza.website

holster.haza.website

The Holster website has been gone since rebuilding i.haza.website, it's now back as a replacement for the github wiki docs with updated information for all API's and better examples ðŸŽ‰

I Haza Website also got some updates as I was working on this, so it now does nice preview navigation while you're editing pages. You can start from one page in preview mode, navigate to another page you're working on and continue editing from there.

There's also a lot of code examples on the site so I added a Copy Code plugin that allows you to copy code blocks if you want to run them interactively in Node. There's also a theme switcher plugin for light and dark mode:
 

Holster 2.3.0

A new Holster release is available that provides await support.

Using Holster for building i.haza.website was very different than working on RSStream as it needed to be much more responsive to Holster data changes. Looking back at the code up until this point, it was full of await new Promise(resolve => { }) wrappers so that state could update in the correct order.

The latest Holster release removes all of this from application code by providing a Thenables interface onto terminal API calls. That sounds weird but it does exactly what you need, which is when you would otherwise provide a callback to the Holster API you can just await the call instead. Internally Holster knows when a callback isn't provided and can extend the response to include a then() function, if you were chaining the request then the extra function is ignored, otherwise it provides your data.

This works for get and next in the API, put requests can also be awaited but they now internally return a promise as they only ever returned an error or null anyway. It allows for simplifying get requests like:
 
// From wrapped calls:
const existing = await new Promise(resolve =>
  user.get("mediaRootId", resolve),
)

// To just:
const existing = await user.get("mediaRootId")
And previously put requests where you waited for the result were:
async function bumpProjectsVersion(user) {
  const now = Date.now()
  return new Promise((resolve, reject) =>
    user
      .get("projectsVersion")
      .put(now, err => (err ? reject(new Error(err)) : resolve(now))),
  )
}
Are now:
async function bumpProjectsVersion(user) {
  const now = Date.now()
  await user.get("projectsVersion").put(now)
  return now
}
It also makes it easier to work with try and catch blocks, but it's also nice that the old callback style isn't effected by these changes when you want to use it.