mirror of
https://github.com/romancm/gamebrary
synced 2024-11-10 05:34:15 +00:00
Updated endpoints to retrieve only necessary info
This commit is contained in:
parent
5045cad4dc
commit
19a17a870f
1 changed files with 12 additions and 1 deletions
|
@ -5,6 +5,7 @@ axios.defaults.headers.common['user-key'] = functions.config().igdb.key;
|
|||
|
||||
const igdbUrl = 'https://api-endpoint.igdb.com';
|
||||
const igdbFields = 'id,name,slug,created_at,updated_at,summary,rating,category,player_perspectives,release_dates,name,cover,platforms,screenshots,videos,websites,esrb,pegi,themes.name,game.name&expand=game,themes,developers,publishers,game_engines,game_modes,genres,platforms,player_perspectives';
|
||||
const igdbFieldsMinimal = 'id,name,slug,rating,name,cover';
|
||||
|
||||
exports.search = functions.https.onRequest((req, res) => {
|
||||
res.set('Access-Control-Allow-Origin', "*")
|
||||
|
@ -21,7 +22,17 @@ exports.games = functions.https.onRequest((req, res) => {
|
|||
|
||||
const { games, platformId } = req.query;
|
||||
|
||||
axios.get(`${igdbUrl}/games/${games}/?fields=${igdbFields}`)
|
||||
axios.get(`${igdbUrl}/games/${games}/?fields=${igdbFieldsMinimal}`)
|
||||
.then(({ data }) => { res.status(200).send(data) })
|
||||
.catch(() => { res.send(400) });
|
||||
});
|
||||
|
||||
exports.game = functions.https.onRequest((req, res) => {
|
||||
res.set('Access-Control-Allow-Origin', "*")
|
||||
|
||||
const { gameId } = req.query;
|
||||
|
||||
axios.get(`${igdbUrl}/games/${gameId}/?fields=${igdbFields}`)
|
||||
.then(({ data }) => { res.status(200).send(data) })
|
||||
.catch(() => { res.send(400) });
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue