@webtask/async-function-middleware
v1.0.0
Published
Webtask middleware that implements an async function programming model
Keywords
Readme
Async function middleware
The async function middleware provides a custom programming model which allows a webtask to directly return results in an idiomatic way.
Usage
To use the async function middleware, you must create a webtask that exports an async function that returns a result:
module.exports = async function (context) {
return { hello: context.query.name || 'Anonymous' };
}Set the
wt-node-dependenciesmetadata property to a stringified JSON of an object having@webtask/middleware-compilerand@webtask/async-function-middlewareproperties whose values are the latest version of the @webtask/middleware-compiler module and this module, respectively. For example:{ "@webtask/middleware-compiler": "1.5.0", "@webtask/async-function-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/async-function-middleware.Issue requests to your webtask
