Function extendRequest

  • Creates a middleware, which extends an IHttpRequest with the props 'requestTime' and 'requestId'.

    Returns HttpMiddleware

    The new middleware.

    Example

    import createServer from '@egomobile/http-server'
    import { extendRequest } from '@egomobile/api-utils'

    const app = createServer()

    // this should be done very first
    app.use( extendRequest() )

    app.get('/', async (request, response) => {
    // now we can access the following props:
    // - request.requestId
    // - request.requestTime
    })

    // ...

    app.listen()
    .catch(console.error);

Generated using TypeDoc