coinratecap / Backend

This is the backend of coinratecap
MIT License
6 stars 6 forks source link

request&response #63

Open NoorAhmd opened 3 years ago

NoorAhmd commented 3 years ago

Hello all, after our group meeting yesterday and as per @Francisca - SM Manager request I am going to discuss a little about how we are going to request from URL and how to provide response.

exports.getCoinPrice = async () => {
    const url = 'https://api.gemini.com/v1/pubticker/btcusd'
    try {
        const response = await got(url, { responseType: 'json' })
            return response.body
    } catch (error) {
          throw new Error(error)
    }
}

and then use it as:

router.get("/price", async (req, res, next) => {
    try {
        const price = await getCoinPrice()
            res.status(200).json({price: price.last, volume: price.volume})
    } catch (error) {
        next(error)
    }
})

I have used got npm package for requesting from URL's and probably will use cron package for cron jobs.

Our response type will be the same for all URL's as {price: last price, volume: volume of exchange} and request might be different(sometimes) depending on the resources provided data.

We have a list of URL's provided by @dhakal0kushal and I will go over them to one by one and update you in comments below.

Francaolisa commented 3 years ago

Okay. What about other features that needs to be analyzed?

NoorAhmd commented 3 years ago

https://github.com/coinratecap/Backend/issues/67#issuecomment-796945486

melodyogonna commented 3 years ago

So the response of this API request is going to be sent straight to the client?