import CascadeService from './src/cascadeService' ; import CascadeProducer from './src/cascadeProducer' ; import CascadeConsumer from './src/cascadeConsumer' ; import * as Types from './src/kafkaInterface' ; module module . exports = { example param kafka param { string } topic param { string } groupId param serviceCB param successCB param dlqCB returns { CascadeService } service : ( kafka , topic , groupId , serviceCB , successCB , dlqCB = ( msg ) => console . log ( 'DLQ Message received' ) ) : Promise < CascadeService > => { return new Promise ( async ( resolve , reject ) => { try { const newServ = new CascadeService ( kafka , topic , groupId , serviceCB , successCB , dlqCB ) ; resolve ( newServ ) ; } catch ( error ) { reject ( error ) ; } } ) ; } , param msg returns { object } getMetadata : ( msg ) : { retires : number ; status : string ; topicArr : string [ ] ; } => { if ( typeof ( msg ) !== 'object' || ! msg . message || ! msg . message . headers || ! msg . message . headers . cascadeMetadata ) return ; return JSON . parse ( msg . message . headers . cascadeMetadata ) ; } , } ; export { CascadeService , CascadeProducer , CascadeConsumer , Types , } ;