_open (callback) { this[kServer].listen(0, () => { debug('active on port %o', this.port) callback() }) }
/** * send message to app * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendToApp(action, data) { debug('[%s] send %s with %j to all app', this.pid, action, data); this.send(action, data, 'app'); return this; }
_onMessage(message) { if (message && is.string(message.action)) { debug('[%s] got message %s with %j, receiverPid: %s', this.pid, message.action, message.data, message.receiverPid); this.emit(message.action, message.data); } }
const processEvent = async ( job: Job<SendGridWebhookEventJobData> ): Promise<void> => { const { event } = job.data; const user = await getUserByEmail(event.email); if (!user) { debug(`No user found with email ${event.email}`); throw new Error(`No user found with email ${event.email}`); } return await deactivateUserEmailNotifications(user.id); }
_onRemove(filePath) { filePath = slash(filePath); const relativePath = path.relative(this.sourcePath, filePath); if ( relativePath.indexOf("node_modules") !== -1 || relativePath.indexOf("zero-builds") !== -1 ) { return; } debug("[REM]".yellow, filePath); if (this.isWatching) this._emitFileChange("remove", filePath); }
const createPayload = (type: EntityTypes, data: Object): Object => debug(`create payload for ${type.toLowerCase()}#${data.id}`) || { type, id: data.id, payload: JSON.stringify(data), }
function _markAsCompleted (db, id) { var completed_at = utils.getCurrentDateTimeAsString() debug('Marking job ID %s as completed at %s', id, completed_at) return db.markAsCompleted(id) }
const removeSubscription = (endpoint: string) => { debug(`remove subscription ${endpoint}`); return db .table('webPushSubscriptions') .getAll(endpoint, { index: 'endpoint' }) .delete() .run(); }
_destroy (reason, cb) { if (reason) debug('destroy %o: %O', this[kTitle], reason) clearTimeout(this[kIdleTimer]) this[kParser].destroy() cb(reason) }
const getSubscriptions = (userId: string) => { debug(`get subscriptions for user#${userId}`); return db .table('webPushSubscriptions') .getAll(userId, { index: 'userId' }) .run(); }
_open (callback) { this[kServer] = this[kApp].listen(0, () => { debug('active on port %o', this.port) callback() }) enableDestroy(this[kServer]) }
/** * send message to agent * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendToAgent(action, data) { debug('[%s] send %s with %j to all agent', this.pid, action, data); this.send(action, data, 'agent'); return this; }
/** * Send message to all agent and app * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ broadcast(action, data) { debug('[%s] broadcast %s with %j', this.pid, action, data); this.send(action, data, 'both'); return this; }
/** * send message to app * @param {String} action - message key * @param {Object} data - message value * @return {Messenger} this */ sendToApp(action, data) { debug('[%s] send %s with %j to all app', this.pid, action, data); this.send(action, data, 'application'); return this; }