0.2.0 • Published 5 years ago

@malijs/metadata v0.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 years ago

@malijs/metadata

Mali metadata middleware

npm version build status

API Reference

@malijs/metadata

Mali metadata middleware. If the call has metadata with the specified property the specified type the middleware function is executed.

ParamTypeDescription
nameStringThe name of the metadata object property
optionsOptions
options.truthyBooleanoptional check for truthiness on the param value within the request. Default: false
fnfunctionThe middleware function to execute

Example

const metadata = require('@malijs/metadata')

async function requestId (requestId, ctx, next) {
  ctx.req.requestId = requestId
  await next()
}

app.use(metadata('requestId', { truthy: true }, requestId))

License

Apache-2.0