arash16 / nuxt-ssr-cache

Cache middleware for nuxt's SSR rendering.
MIT License
295 stars 64 forks source link

idea: rewrite as a nuxt module #1

Closed pi0 closed 5 years ago

pi0 commented 5 years ago

Hi @arash16.

I really like what you did for implementing renderer-level caching for Nuxt. Nice job :+1:

Nuxt.js is designed to be extended via modules. While providing API for using programmatically I highly recommend implementing it as a module.

Read more: https://nuxtjs.org/guide/modules

Change should not be really hard. The module exports a function which has access to all internals:

import { cacheRenderer } from './middleware'

export default function (options) {
  cacheRenderer(this.nuxt, options)
}

Happy hacking :)

arash16 commented 5 years ago

Thanks @pi0 I fixed it :+1:

pi0 commented 5 years ago

Clever refactor :+1: