API Reference
function convertExpressMiddleware
Purpose
This function converts express middleware to papupata middleware. While papupata can use express middleware directly on individual APIs, the support is somewhat limited as express middleware is always called before any papupata middleware. By converting the middleware you have more control over the invocation order, and it also allows the use of express middleware as inherent middleware.Availability
This functionality is available from papupata version 1.5.0 onwards.Usage
Simply call the function and pass express middleware as a parameter to create a papupata middleware out of it. Error handling express middleware is not supported at this time.
Parameters
Name | Type | Description |
---|---|---|
expressMiddleware | Express middleware | An express middleware function. |
Returns
PapupataMiddlewareExamples
import bodyParser from 'body-parser'
import { APIDeclaration, convertExpressMiddleware } from 'papupata'
const ppBodyParser = convertExpressMiddleware(bodyParser)
const API = new APIDeclaration()
API.configure({inherentMiddleware: [ppBodyParser]})