Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.websocketHandler = void 0; const websocketHandler = async (event, context, config) => { const { action } = JSON.parse(event.body); let runData = {}; for (const configMW of config.middlewares) { runData = await configMW(event, context, runData); } let handler = Promise.resolve({}); for (const configAction of config.actions) { if (configAction.name === action) { !config.enableLogging || console.log(`Executing action ${action}`); handler = configAction.handler(event, context, runData); } else if (config.fallback) { !config.enableLogging || console.log(`Executing fallback as there were no ${action}`); handler = config.fallback(event, context, runData); } else { handler = Promise.reject({ statusCode: 400, body: 'No action specified' }); } } return handler; }; exports.websocketHandler = websocketHandler; |