import { BeforeDBNote, DeleteNoteDTO, NoteItem, NotesEvents } from '../../../typings/notes'; import NotesService from './notes.service'; import { notesLogger } from './notes.utils'; import { onNetPromise } from '../utils/PromiseNetEvents/onNetPromise'; onNetPromise(NotesEvents.ADD_NOTE, (reqObj, resp) => { NotesService.handleAddNote(reqObj, resp).catch((e) => { notesLogger.error(`Error occured in add note event (${reqObj.source}), Error: ${e.message}`); resp({ status: 'error', errorMsg: 'UNKNOWN_ERROR' }); }); }); onNetPromise(NotesEvents.FETCH_ALL_NOTES, (reqObj, resp) => { NotesService.handleFetchNotes(reqObj, resp).catch((e) => { notesLogger.error( `Error occurred in fetch note event (${reqObj.source}), Error: ${e.message}`, ); resp({ status: 'error', errorMsg: 'UNKNOWN_ERROR' }); }); }); onNetPromise(NotesEvents.DELETE_NOTE, async (reqObj, resp) => { NotesService.handleDeleteNote(reqObj, resp).catch((e) => { notesLogger.error( `Error occured in delete note event (${reqObj.source}), Error: ${e.message}`, ); resp({ status: 'error', errorMsg: 'UNKNOWN_ERROR' }); }); }); onNetPromise(NotesEvents.UPDATE_NOTE, async (reqObj, resp) => { NotesService.handleUpdateNote(reqObj, resp).catch((e) => { notesLogger.error(`Error occured in fetch note event (${reqObj.source}), Error: ${e.message}`); resp({ status: 'error', errorMsg: 'UNKNOWN_ERROR' }); }); });