const middy = require('middy')
const calculateCacheId = (event,context,callback) => {
console.log("fffff-----------"+JSON.stringify(event));
}
const cacheMiddleware = () => {
return ({
before: (handler, next) => {
handler.event['statusd']=false;
console.log("--opppp");
if(handler.event.authorizationToken=="ggfgyuhkhkghghghhj"){
event['statusd']=true;
return handler.callback(null,{"po":"ik"});
}
return next()
}
})
}
// sample usage
const handler = middy((event, context, callback) => {
console.log("dta-------------",event.statusd);
if(event.statusd){
callback(null,JSON.stringify({"fdf":"fdfdffd"}));
} else {
callback(null,JSON.stringify({"name":"pawan"}));
}
})
.use(cacheMiddleware())
module.exports = { handler }
const calculateCacheId = (event,context,callback) => {
console.log("fffff-----------"+JSON.stringify(event));
}
const cacheMiddleware = () => {
return ({
before: (handler, next) => {
handler.event['statusd']=false;
console.log("--opppp");
if(handler.event.authorizationToken=="ggfgyuhkhkghghghhj"){
event['statusd']=true;
return handler.callback(null,{"po":"ik"});
}
return next()
}
})
}
// sample usage
const handler = middy((event, context, callback) => {
console.log("dta-------------",event.statusd);
if(event.statusd){
callback(null,JSON.stringify({"fdf":"fdfdffd"}));
} else {
callback(null,JSON.stringify({"name":"pawan"}));
}
})
.use(cacheMiddleware())
module.exports = { handler }