hypernova icon indicating copy to clipboard operation
hypernova copied to clipboard

Add middlewares to the config. (This can be useful if you want to pro…

Open denimamab opened this issue 4 years ago • 3 comments

…cess some treatment after the body-parser.)

denimamab avatar Aug 16 '21 16:08 denimamab

Can you elaborate about your use cases?

ljharb avatar Aug 16 '21 19:08 ljharb

@ljharb Hello,

The use case is to implement a middleware that can read the body for each job and compare the version number with the hypernova-server version number. That assure to re-render the component if the cache version is not valid with the HS version and serve the urls for the right assets (js + css) in the meta field.

Monolithe: construct the jobs to process (if the job is already in a distributed cache [Eg. redis] we set a flag that the job is already in cache and here is the cache version => hypernova-server intercept these jobs and should process only the jobs that are not cache valid.

This answers the problem of cache invalidation strategy when deploying newer version of hypernova-service.

denimamab avatar Aug 18 '21 07:08 denimamab

you can access the express app by passing in a onServer callback to hypernova(config, onServer), that way you can add your middlewares after body-parser https://github.com/airbnb/hypernova/blob/master/src/worker.js#L124

nksfrank avatar Dec 14 '21 08:12 nksfrank