From 2bec41634e3cb08dcc39933f2623be287c4cf13e Mon Sep 17 00:00:00 2001 From: Marcos Corona Date: Fri, 2 Oct 2020 17:14:53 -0300 Subject: [PATCH] Remove async in astrologer.house function --- src/api/index.js | 2 +- src/astrologer/houses.js | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 3ffdcbc..89a31a0 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -17,7 +17,7 @@ router.get('/horoscope', async (req, res) => { return accumulator; }, {}); - const houses = await astrologer.houses(date, { + const houses = astrologer.houses(date, { latitude: parseFloat(req.query.latitude), longitude: parseFloat(req.query.longitude), }); diff --git a/src/astrologer/houses.js b/src/astrologer/houses.js index 37a21aa..44ed95a 100644 --- a/src/astrologer/houses.js +++ b/src/astrologer/houses.js @@ -2,7 +2,7 @@ const swisseph = require('swisseph'); swisseph.swe_set_ephe_path(`${__dirname}/../../eph`); -const { utcToJulianUt, degreesToDms, zodiacSign } = require('astrologer/utils') +const { utcToJulianUt, degreesToDms, zodiacSign } = require('astrologer/utils'); /** * Position type @@ -31,9 +31,9 @@ const { utcToJulianUt, degreesToDms, zodiacSign } = require('astrologer/utils') * @param {Position} position * @return {{axes: Object, houses: House[]}} */ -const houses = async (date, position) => { +const houses = (date, position) => { const julianDayUT = utcToJulianUt(date); - const {house, ...rawAxes} = swisseph.swe_houses(julianDayUT, position.latitude, position.longitude, 'P') + const { house, ...rawAxes } = swisseph.swe_houses(julianDayUT, position.latitude, position.longitude, 'P'); const axes = { asc: { @@ -52,17 +52,16 @@ const houses = async (date, position) => { position: degreesToDms(rawAxes.mc + 180), // this should to be equal to mc but with opposite sign sign: zodiacSign((rawAxes.mc + 180)) }, - } + }; - const houses = Array.from(house).map(cuspid => { - return { + return { + axes, + houses: Array.from(house).map((cuspid) => ({ position: degreesToDms(cuspid), sign: zodiacSign(cuspid) - } - }) - - return {axes, houses}; -} + })) + }; +}; module.exports = { houses,