Pambda to handle Redux action.
npm i pambda-redux -S
import { compose, createLambda } from 'pambda';
import { router } from 'pambda-router';
import { jsonApi } from 'pambda-json-api';
import { redux } from 'pambda-redux';
export const handler = createLambda(
compose(
router()
.post('/api/', compose(
jsonApi({}),
redux({})
))
.toPambda()
)
);
handlers/MY_ACTION.js
export default (event, context, callback) => {
// Do something for type MY_ACTION
};
options.handlers
- The object with a handler according to type of Action. The type of Action is specified for the key. For the value, a function with the argument
(event, context, callback)
is specified.
- The object with a handler according to type of Action. The type of Action is specified for the key. For the value, a function with the argument
options.basedir
- Base directory that a module is required.
- When a corresponding handler for type of Action can not be found in
handlers
, require a module that matches type in its base directory. Thedefault
function in the module is called as a handler. - The default value is
process.cwd() + '/handlers'
.
options.invalidRequestHandler
- A function with an argument
(event, context, callback)
called for an invalid request.
- A function with an argument
options.unknownTypeHandler
- A function with an argument
(event, context, callback)
called for an unknown type.
- A function with an argument
MIT