UNPKG

@fabric-es/fabric-cqrs

Version:

Hyperledger Fabric middleware for event sourcing and cqrs pattern

21 lines 1.26 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = __importDefault(require("util")); const redux_observable_1 = require("redux-observable"); const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); const action_1 = require("../action"); const { GET_NOTIFICATION, getNotiSuccess, getNotiError } = action_1.action; exports.default = (action$, _, { queryDatabase, logger }) => action$.pipe(redux_observable_1.ofType(GET_NOTIFICATION), operators_1.map(({ payload }) => payload), operators_1.mergeMap(({ tx_id, args: { creator, entityName, commitId, id } }) => rxjs_1.from(queryDatabase .getNotification({ creator, entityName, commitId, id }) .then(({ data, status, errors }) => status === 'OK' ? getNotiSuccess({ tx_id, result: data }) : getNotiError({ tx_id, error: errors })) .catch((error) => { logger.error(util_1.default.format('[store/query/getNotification.js] fail to %s: tx_id:%s, %j', GET_NOTIFICATION, tx_id, error)); return getNotiError({ tx_id, error: error.message }); })))); //# sourceMappingURL=getNotification.js.map