Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.
/ mookie Public archive

🙈Node.js middleware engine for AWS Lambda using async functions

License

Notifications You must be signed in to change notification settings

kevinrambaud/mookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 mookie
build-status build-status build-status build-status

Node.js middleware engine for AWS Lambda using async functions.

Installation

npm install mookie

Usage

const mookie = require('mookie')

function debug(v) {
  console.log(JSON.stringify(v, null, 2), '\n')
}

async function error(handler, next) {
  try {
    await next()
  } catch (err) {
    console.log(err.message)
  }
}

async function inputOutputLogger(handler, next) {
  debug({ event: handler.event })
  await next()
  debug({ response: handler.response })
}

async function myLambdaFunction(event, context) {
  return {
    event,
    context,
    message: 'Hello world!'
  }
}

exports.handler = mookie(myLambdaFunction)
  .use(error)
  .use(inputOutputLogger)