How to use the single-user-cache.Factory function in single-user-cache

To help you get started, we’ve selected a few single-user-cache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mcollina / fastify-gql / index.js View on Github external
fastifyGraphQl.defineLoaders = function (loaders) {
    // set up the loaders factory
    if (!factory) {
      factory = new Factory()
      app.decorateReply(kLoaders)
      app.addHook('onRequest', async function (req, reply) {
        reply[kLoaders] = factory.create({ req, reply, app })
      })
    }

    function defineLoader (name) {
      // async needed because of throw
      return async function (obj, params, { reply }) {
        if (!reply) {
          throw new Error('loaders only work via reply.graphql()')
        }
        return reply[kLoaders][name]({ obj, params })
      }
    }

single-user-cache

A cache for a single user

MIT
Latest version published 9 months ago

Package Health Score

58 / 100
Full package analysis

Popular single-user-cache functions