actions.js 509 Bytes
/**
 * Actions
 *
 * @author: Aiden Xu<aiden.xu@yoho.cn>
 * @date: 2016/7/11
 */
'use strict';

const AbstractAction = require('./abstract-action');

/**
 * 创建 Action
 * @param Action
 * @returns {Function}
 */
const createAction = Action => {
    return ((req, res, next) => {
        const ret = new Action(req, res, next)._render();

        if (ret && typeof Promise.catch === 'function') {
            ret.catch(next);
        }
    });
};

module.exports = {
    createAction,
    AbstractAction
};