Skip to content

Commit

Permalink
Remove async in astrologer.house function
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuphi committed Oct 2, 2020
1 parent 00db1d2 commit 2bec416
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
Expand Down
21 changes: 10 additions & 11 deletions src/astrologer/houses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand All @@ -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,
Expand Down

0 comments on commit 2bec416

Please sign in to comment.