Skip to content

`customKey` middleware and new `createKey` algo

Choose a tag to compare

@neurosnap neurosnap released this 06 Feb 18:37
· 33 commits to main since this release
3f48591

This releases adds a new middleware customKey which is loaded into the requestMonitor middleware. The benefit of this middleware is users can now override the auto-generated ctx.key inside their middleware:

const fetchUsers = api.create('/users', function*(ctx, next) {
  ctx.key = 'fetch-users-key';
  yield next();
})

ctx.key is used for automatic caching.

We also modified the algorithm for generating the key automatically. Instead of a base64 encoding we are now performing a hash (pulled from https://gist.github.com/iperelivskiy/4110988).