@webtask/optional-compiler-middleware v1.0.0
Optional compiler middleware
The optional compiler middleware enables advanced middleware usage such as implementing compilers as middleware or even composable compilers. @webtask/middleware-compiler plays a fundamental role in enabling middleware functions and one of its core assumptions is that the underlying webtask script (located at req.webtaskContext.compiler.script) is a string. It would be convenient to be able to reassign the webtask script to a compiled Function object when implementing a compiler. Unfortunately, this breaks the assumption made by @webtask/middleware-compiler (or even other userspace middleware functions) that it is safe to call nodejsCompiler on req.webtaskContext.compiler.script. This middleware decorates the nodejsCompiler with optional compilation based on the type of the webtask script.
Usage
Set the
wt-node-dependenciesmetadata property to the stringified JSON of an object having@webtask/middleware-compilerand@webtask/optional-compiler-middlewareproperties whose values are the latest version of the @webtask/middleware-compiler module and this module, respectively.{ "@webtask/middleware-compiler": "1.5.0", "@webtask/optional-compiler-middleware": "1.0.0" }Set the
wt-compilermetadata property on your webtask to@webtask/middleware-compiler.Set (or add to) the
wt-middlewaremetadata property of your webtask to contain a comma-separated list containing@webtask/optional-compiler-middleware.Issue requests to your webtask
7 years ago