From 76ecb6b9a9a35e16671e39e068c9afd652d898a2 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 27 Feb 2020 14:21:51 -0400 Subject: [PATCH] log data before sending --- services/gunDB/contact-api/utils/index.js | 6 ++++-- src/routes.js | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index c34a143b..03758c87 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -34,8 +34,9 @@ const timeout10 = promise => { // @ts-ignore let timeoutID return Promise.race([ - promise.then(() => { + promise.then((v) => { clearTimeout(timeoutID) + return v }), new Promise((_, rej) => { @@ -56,8 +57,9 @@ const timeout5 = promise => { // @ts-ignore let timeoutID return Promise.race([ - promise.then(() => { + promise.then((v) => { clearTimeout(timeoutID) + return v }), new Promise((_, rej) => { diff --git a/src/routes.js b/src/routes.js index 4689b621..fa4cc87e 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1625,8 +1625,10 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_AVATAR}`, async (_, res) => { try { + const data = await timeout5(user.get(Key.PROFILE).get(Key.AVATAR).then()) + logger.info(`avatar poll:${data}`) res.json({ - data: await timeout5(user.get(Key.PROFILE).get(Key.AVATAR).then()) + data }) } catch (err) { logger.info('Error in Avatar poll:') @@ -1639,8 +1641,10 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, async (_, res) => { try { + const data = await timeout5(user.get(Key.PROFILE).get(Key.DISPLAY_NAME).then()) + logger.info(`display name poll:${data}`) res.json({ - data: await timeout5(user.get(Key.PROFILE).get(Key.DISPLAY_NAME).then()) + data }) } catch (err) { logger.info('Error in Display Name poll:') @@ -1653,8 +1657,10 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_HANDSHAKE_ADDRESS}`, async (_, res) => { try { + const data = await timeout5(user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then()) + logger.info(`handshake address poll:${data}`) res.json({ - data: await timeout5(user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then()) + data }) } catch (err) { logger.info('Error in Handshake Address poll:') @@ -1667,8 +1673,10 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_BIO}`, async (_, res) => { try { + const data = await timeout5(user.get(Key.BIO).then()) + console.log(data) res.json({ - data: await timeout5(user.get(Key.BIO).then()) + data }) } catch (err) { logger.info('Error in BIO poll:')