src/http/app.js
function createHandler(options) {
  /**
   * Client request handler
   * Data from the incoming request (plus options) is forwarded to the AWS module
   */
  return async (ctx) => {
    const { credentials, endpoint, region } = options
    const { rawBody: body, header: headers, method, url: path } = ctx.request

    console.log(chalk.cyan(method, path))

    const params = { body, credentials, endpoint, headers, method, path, region }
    const req = createSignedAWSRequest(params)
    const res = await sendAWSRequest(req)

    ctx.status = 200
    ctx.type = 'application/json'
    ctx.response.header = stripProxyResHeaders(res)
    ctx.body = res.body
  }
}
function createHandler(options) {
  /**
   * Client request handler
   * Data from the incoming request (plus options) is forwarded to the AWS module
   */
  return async (ctx) => {
    const { credentials, endpoint, region } = options
    const { rawBody: body, header: headers, method, url: path } = ctx.request

    console.log(chalk.cyan(method, path))

    const params = { body, credentials, endpoint, headers, method, path, region }
    const req = createSignedAWSRequest(params)
    const res = await sendAWSRequest(req)

    ctx.status = 200
    ctx.type = 'application/json'
    ctx.response.header = stripProxyResHeaders(res)
    ctx.body = res.body
  }
}
function createHandler ( options ) { /**
   * Client request handler
   * Data from the incoming request (plus options) is forwarded to the AWS module
   */ return async ( ctx ) => { const { credentials , endpoint , region } = options const { rawBody : body , header : headers , method , url : path } = ctx . request console . log ( chalk . cyan ( method , path ) ) const params = { body , credentials , endpoint , headers , method , path , region } const req = createSignedAWSRequest ( params ) const res = await sendAWSRequest ( req ) ctx . status = 200 ctx . type = 'application/json' ctx . response . header = stripProxyResHeaders ( res ) ctx . body = res . body } }
Creates request handler middleware
@param {Object} options.credentials  - aws credentials object
@param {Object} options.endpoint     - aws elasticsearch endpoint
@param {Object} options.region       - aws region
Creates request handler middleware