mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
refactor(server/contacts): Implement singleton architecture
This commit is contained in:
1 parent
16471ed1df
commit
f8f722c8d2
9 files changed
+200
-136
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { Contact, ContactEvents, PreDBContact } from '../../../typings/contact';
|
||||
import { getSource } from '../utils/miscUtils';
|
||||
import ContactService from './contacts.service';
|
||||
import { contactsLogger } from './contacts.utils';
|
||||
|
||||
onNet(ContactEvents.GET_CONTACTS, async (limit: number) => {
|
||||
const src = getSource();
|
||||
ContactService.handleFetchContact(src, limit).catch((e) =>
|
||||
contactsLogger.error(`Error occured in fetch contacts event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(ContactEvents.ADD_CONTACT, async (contact: PreDBContact) => {
|
||||
const src = getSource();
|
||||
ContactService.handleAddContact(src, contact).catch((e) =>
|
||||
contactsLogger.error(`Error occured in fetch contacts event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(ContactEvents.UPDATE_CONTACT, async (contact: Contact) => {
|
||||
const src = getSource();
|
||||
ContactService.handleUpdateContact(src, contact).catch((e) =>
|
||||
contactsLogger.error(`Error occured in update contact event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(ContactEvents.DELETE_CONTACT, async (contactId: number) => {
|
||||
const src = getSource();
|
||||
ContactService.handleDeleteContact(src, contactId).catch((e) =>
|
||||
contactsLogger.error(`Error occured in delete contact event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user