attach(app) {
    // Intercept request to get from cache if possible
    app.use(this.cacheRoute.bind(this))

    // Any requests after this will be stored in cache.
    // TODO: figure out if I should homogenize requests by invoking hydrate here
    // app.use(intercept.json((json, req, res) => this.cacheSet(req.cacheKey, json)))
    // json is not needed since it invokes send on its own.
    app.use(intercept.write((buffer, encoding, req, res) => this.cacheSet(req.cacheKey, buffer)))
    app.use(intercept.send((chunk, req, res) => this.cacheSet(req.cacheKey, chunk)))
  }
/**
   * A function to attach this middleware to an Express instance.
   * This is necessary because there are multiple layers to attach.
   * Perhaps if mung ever gets a single total interception middleware, we can just return the route.
   * @param  {ExpressApp} app The Express app instance.
   */
A function to attach this middleware to an Express instance.
This is necessary because there are multiple layers to attach.
Perhaps if mung ever gets a single total interception middleware, we can just return the route.
@param  {ExpressApp} app The Express app instance.
A function to attach this middleware to an Express instance . This is necessary because there are multiple layers to attach . Perhaps if mung ever gets a single total interception middleware we can just return the route . @param { ExpressApp } app The Express app instance .
attach(app) {
    app.use(this.cacheRoute.bind(this))
    app.use(intercept.write((buffer, encoding, req, res) => this.cacheSet(req.cacheKey, buffer)))
    app.use(intercept.send((chunk, req, res) => this.cacheSet(req.cacheKey, chunk)))
  }
attach ( app ) { app . use ( this . cacheRoute . bind ( this ) ) app . use ( intercept . write ( ( buffer , encoding , req , res ) => this . cacheSet ( req . cacheKey , buffer ) ) ) app . use ( intercept . send ( ( chunk , req , res ) => this . cacheSet ( req . cacheKey , chunk ) ) ) }
A function to attach this middleware to an Express instance.
A function to attach this middleware to an Express instance .
// Intercept request to get from cache if possible // Any requests after this will be stored in cache. // TODO: figure out if I should homogenize requests by invoking hydrate here // app.use(intercept.json((json, req, res) => this.cacheSet(req.cacheKey, json))) // json is not needed since it invokes send on its own.