Skip to content

malijs/param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@malijs/param

Mali request param middleware

npm version build status

API

@malijs/param

Mali param middleware. If the request object has the specified property of specified type the middleware function is executed. Only applies for UNARY and RESPONSE_STREAM call types.

Param Type Description
paramName String The name of the request object property
options Options
options.type String Optional type of the param specified by paramName within the request. Has to be one of possible values as returned by typeof.
options.truthy Boolean optional check for truthiness on the param value within the request. Default: false
fn function The middleware function to execute

Example

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

async function appendDocType (id, ctx, next) {
  ctx.req.id = 'user::'.concat(id)
  await next()
}

app.use(param('id', { type'string', truthy: true }, appendDocType))

License

Apache-2.0

About

Mali request param middleware

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors