jsdevkr / gitCodeShare.com

Contributhon 2018 - gitCodeShare.com (a.k.a gitShare)
https://gitcodeshare.com
MIT License
76 stars 21 forks source link

[Request to Backend] We seems to need github api #138

Closed currybob closed 6 years ago

currybob commented 6 years ago
2018-10-04 12 48 25

This page needs data that contains user name, job, and bio. but when requested, the return data is like that.

2018-10-04 12 26 08

To get other data, we usually needs re-request for a property marked as "url" Not only this case, separating the api for Github data seems to be more efficient. because we will be getting more star, fork, or more data about the user who wrote the code.

I would appreciate if anyone could comment on this issue

gimdongwoo commented 6 years ago

We will use a cache layer. Our many requests are not a problem.

gimdongwoo commented 6 years ago

https://www.npmjs.com/package/cache-manager

This is a example on express server.

const cacheManager = require('cache-manager')
const axios = require('axios')

const cache = cacheManager.caching({
  store: 'memory',
  ttl: 30,
})

async function getEventData(eventId) {
  const cacheKey = `event-${eventId}`

  return await cache.wrap(cacheKey, async () => {
    return await axios.get(`/v1/event/${eventId}`)
  })
}
gimdongwoo commented 6 years ago

@aeei help you.