use once() (then())

This commit is contained in:
Daniel Lugo 2020-02-21 16:56:31 -04:00
parent 6179c4139b
commit e8f7e167c4

View file

@ -1566,6 +1566,7 @@ module.exports = async (
const GunEvent = require('../services/gunDB/event-constants') const GunEvent = require('../services/gunDB/event-constants')
const Events = require('../services/gunDB/contact-api/events') const Events = require('../services/gunDB/contact-api/events')
const user = require('../services/gunDB/Mediator').getUser() const user = require('../services/gunDB/Mediator').getUser()
const Key = require('../services/gunDB/contact-api/key')
app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => { app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => {
try { 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 { try {
// spinup
Events.onAvatar(() => {}, user )()
const data = Events.getAvatar()
res.json({ res.json({
data data: await user.get(Key.PROFILE).get(Key.AVATAR).then()
}) })
} catch (err) { } catch (err) {
res.status(500).json({ 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 { try {
// spinup
Events.onDisplayName(() => {}, user)()
const data = Events.getDisplayName()
res.json({ res.json({
data data: await user.get(Key.PROFILE).get(Key.DISPLAY_NAME).then()
}) })
} catch (err) { } catch (err) {
res.status(500).json({ 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 { try {
// spinup
Events.onCurrentHandshakeAddress(() => {}, user)()
const data = Events.getHandshakeAddress()
res.json({ res.json({
data data: await user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then()
}) })
} catch (err) { } catch (err) {
res.status(500).json({ res.status(500).json({