From e8f7e167c4f2cd027fe4471c11c524e0d487e843 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 21 Feb 2020 16:56:31 -0400 Subject: [PATCH] use once() (then()) --- src/routes.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/routes.js b/src/routes.js index 523c488c..8b30f91f 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1566,6 +1566,7 @@ module.exports = async ( const GunEvent = require('../services/gunDB/event-constants') const Events = require('../services/gunDB/contact-api/events') const user = require('../services/gunDB/Mediator').getUser() + const Key = require('../services/gunDB/contact-api/key') app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => { try { @@ -1612,13 +1613,10 @@ module.exports = async ( } }) - app.get(`/api/gun/${GunEvent.ON_AVATAR}`, (_, res) => { + app.get(`/api/gun/${GunEvent.ON_AVATAR}`, async (_, res) => { try { - // spinup - Events.onAvatar(() => {}, user )() - const data = Events.getAvatar() res.json({ - data + data: await user.get(Key.PROFILE).get(Key.AVATAR).then() }) } catch (err) { res.status(500).json({ @@ -1627,13 +1625,10 @@ module.exports = async ( } }) - app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, (_, res) => { + app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, async (_, res) => { try { - // spinup - Events.onDisplayName(() => {}, user)() - const data = Events.getDisplayName() res.json({ - data + data: await user.get(Key.PROFILE).get(Key.DISPLAY_NAME).then() }) } catch (err) { res.status(500).json({ @@ -1642,13 +1637,10 @@ module.exports = async ( } }) - app.get(`/api/gun/${GunEvent.ON_HANDSHAKE_ADDRESS}`, (_, res) => { + app.get(`/api/gun/${GunEvent.ON_HANDSHAKE_ADDRESS}`, async (_, res) => { try { - // spinup - Events.onCurrentHandshakeAddress(() => {}, user)() - const data = Events.getHandshakeAddress() res.json({ - data + data: await user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then() }) } catch (err) { res.status(500).json({