diff --git a/functions/index.js b/functions/index.js index 96f877e9..20c48460 100755 --- a/functions/index.js +++ b/functions/index.js @@ -18,7 +18,7 @@ admin.initializeApp({ exports.steam = require('./steam'); exports.customSearch = functions.https.onRequest((req, res) => { - res.set('Access-Control-Allow-Origin', "*"); + res.set('Access-Control-Allow-Origin', '*'); if (!req.query.token) { return res.status(400).json({ error: 'missing searchText or token' }); @@ -53,13 +53,13 @@ exports.customSearch = functions.https.onRequest((req, res) => { ${limit} ${query}`; - axios({ + return axios({ url: 'https://api.igdb.com/v4/games', method: 'POST', headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Client-ID': functions.config().twitch.clientid, - 'Authorization': `Bearer ${req.query.token}`, + Authorization: `Bearer ${req.query.token}`, }, data, }) @@ -309,3 +309,22 @@ exports.email = functions.https.onRequest((req, res) => { .then(({ data }) => { res.status(200).send(data) }) .catch((error) => { res.send(error) }); }); + +// https://gogapidocs.readthedocs.io/en/latest/listing.html +exports.gog = functions.https.onRequest((req, res) => { + res.set('Access-Control-Allow-Origin', '*'); + + const { search } = req.query; + if (!search) return res.status(400).send('Missing search param'); + + axios({ + url: `https://embed.gog.com/games/ajax/filtered?mediaType=game&search=${search}`, + method: 'GET', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/json', + }, + }) + .then(({ data }) => res.status(200).send(data)) + .catch(error => res.send(error)); +}); diff --git a/functions/steam.js b/functions/steam.js index b804b15a..6525222b 100644 --- a/functions/steam.js +++ b/functions/steam.js @@ -3,8 +3,27 @@ const axios = require('axios'); // const BASE_URL = // TODO: put base url in constant +exports.game = functions.https.onRequest((req, res) => { + res.set('Access-Control-Allow-Origin', '*'); + + const { gameId } = req.query; + + if (!gameId) res.status(400).send('Missing steam gameId'); + + axios({ + url: `https://store.steampowered.com/api/appdetails?appids=${gameId}`, + method: 'GET', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/json', + }, + }) + .then(({ data }) => res.status(200).send(data)) + .catch(error => res.send(error)); +}); + exports.news = functions.https.onRequest((req, res) => { - res.set('Access-Control-Allow-Origin', "*") + res.set('Access-Control-Allow-Origin', '*'); const { appId } = req.query; if (!appId) res.send(400); @@ -14,15 +33,15 @@ exports.news = functions.https.onRequest((req, res) => { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded', - 'Accept': 'application/json', + Accept: 'application/json', }, }) .then(({ data }) => res.status(200).send(data)) - .catch((error) => res.send(error)); + .catch(error => res.send(error)); }); exports.friends = functions.https.onRequest((req, res) => { - res.set('Access-Control-Allow-Origin', "*") + res.set('Access-Control-Allow-Origin', '*'); const { appId } = req.query; if (!appId) res.send(400); @@ -32,15 +51,15 @@ exports.friends = functions.https.onRequest((req, res) => { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded', - 'Accept': 'application/json', + Accept: 'application/json', }, }) .then(({ data }) => res.status(200).send(data)) - .catch((error) => res.send(error)); + .catch(error => res.send(error)); }); exports.ownedGames = functions.https.onRequest((req, res) => { - res.set('Access-Control-Allow-Origin', "*") + res.set('Access-Control-Allow-Origin', '*'); const { appId } = req.query; if (!appId) res.send(400); @@ -50,15 +69,15 @@ exports.ownedGames = functions.https.onRequest((req, res) => { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded', - 'Accept': 'application/json', + Accept: 'application/json', }, }) .then(({ data }) => res.status(200).send(data)) - .catch((error) => res.send(error)); + .catch(error => res.send(error)); }); exports.gameList = functions.https.onRequest((req, res) => { - res.set('Access-Control-Allow-Origin', "*") + res.set('Access-Control-Allow-Origin', '*'); const { appId } = req.query; if (!appId) res.send(400); @@ -68,9 +87,9 @@ exports.gameList = functions.https.onRequest((req, res) => { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded', - 'Accept': 'application/json', + Accept: 'application/json', }, }) .then(({ data }) => res.status(200).send(data)) - .catch((error) => res.send(error)); + .catch(error => res.send(error)); }); diff --git a/index.html b/index.html index f65de419..5f26faf7 100755 --- a/index.html +++ b/index.html @@ -22,6 +22,7 @@ Gamebrary diff --git a/src/components/Game/GameRating.vue b/src/components/Game/GameRating.vue index 5f26043e..8853c617 100644 --- a/src/components/Game/GameRating.vue +++ b/src/components/Game/GameRating.vue @@ -1,6 +1,6 @@ @@ -36,7 +34,6 @@ import { LINKS_CATEGORIES } from '@/constants'; export default { props: { game: Object, - grid: Boolean, }, computed: { @@ -53,17 +50,3 @@ export default { }, }; - - diff --git a/src/components/GameCards/GameCardDefault.vue b/src/components/GameCards/GameCardDefault.vue index 551f44da..60a79e05 100644 --- a/src/components/GameCards/GameCardDefault.vue +++ b/src/components/GameCards/GameCardDefault.vue @@ -1,7 +1,7 @@