2021-10-04 20:59:54 +00:00
|
|
|
const functions = require('firebase-functions');
|
|
|
|
const axios = require('axios');
|
2022-03-18 16:31:54 +00:00
|
|
|
|
|
|
|
const STEAM_BASE_URL = 'https://api.steampowered.com';
|
2021-10-04 20:59:54 +00:00
|
|
|
|
2022-02-26 01:49:00 +00:00
|
|
|
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));
|
|
|
|
});
|
|
|
|
|
2021-10-04 20:59:54 +00:00
|
|
|
exports.news = functions.https.onRequest((req, res) => {
|
2022-02-26 01:49:00 +00:00
|
|
|
res.set('Access-Control-Allow-Origin', '*');
|
2021-10-04 20:59:54 +00:00
|
|
|
const { appId } = req.query;
|
|
|
|
|
|
|
|
if (!appId) res.send(400);
|
|
|
|
|
|
|
|
axios({
|
2022-03-18 16:31:54 +00:00
|
|
|
url: `${STEAM_BASE_URL}/ISteamNews/GetNewsForApp/v0002/?appid=${appId}`,
|
2021-10-04 20:59:54 +00:00
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
2022-02-26 01:49:00 +00:00
|
|
|
Accept: 'application/json',
|
2021-10-04 20:59:54 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => res.status(200).send(data))
|
2022-02-26 01:49:00 +00:00
|
|
|
.catch(error => res.send(error));
|
2021-10-04 20:59:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
exports.friends = functions.https.onRequest((req, res) => {
|
2022-02-26 01:49:00 +00:00
|
|
|
res.set('Access-Control-Allow-Origin', '*');
|
2021-10-04 20:59:54 +00:00
|
|
|
const { appId } = req.query;
|
|
|
|
|
|
|
|
if (!appId) res.send(400);
|
|
|
|
|
|
|
|
axios({
|
2022-03-18 16:31:54 +00:00
|
|
|
url: `${STEAM_BASE_URL}/ISteamUser/GetFriendList/v1?key=0DFD0511A922896D8064A4EABC32BE08&steamid=76561198017003200`,
|
2021-10-04 20:59:54 +00:00
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
2022-02-26 01:49:00 +00:00
|
|
|
Accept: 'application/json',
|
2021-10-04 20:59:54 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => res.status(200).send(data))
|
2022-02-26 01:49:00 +00:00
|
|
|
.catch(error => res.send(error));
|
2021-10-04 20:59:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
exports.ownedGames = functions.https.onRequest((req, res) => {
|
2022-02-26 01:49:00 +00:00
|
|
|
res.set('Access-Control-Allow-Origin', '*');
|
2021-10-04 20:59:54 +00:00
|
|
|
const { appId } = req.query;
|
|
|
|
|
|
|
|
if (!appId) res.send(400);
|
|
|
|
|
|
|
|
axios({
|
2022-03-18 16:31:54 +00:00
|
|
|
url: `${STEAM_BASE_URL}/IPlayerService/GetOwnedGames/v0001/?key=0DFD0511A922896D8064A4EABC32BE08&steamid=76561198017003200&include_appinfo=true&format=json`,
|
2021-10-04 20:59:54 +00:00
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
2022-02-26 01:49:00 +00:00
|
|
|
Accept: 'application/json',
|
2021-10-04 20:59:54 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => res.status(200).send(data))
|
2022-02-26 01:49:00 +00:00
|
|
|
.catch(error => res.send(error));
|
2021-10-04 20:59:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
exports.gameList = functions.https.onRequest((req, res) => {
|
2022-02-26 01:49:00 +00:00
|
|
|
res.set('Access-Control-Allow-Origin', '*');
|
2021-10-04 20:59:54 +00:00
|
|
|
const { appId } = req.query;
|
|
|
|
|
|
|
|
if (!appId) res.send(400);
|
|
|
|
|
|
|
|
axios({
|
2022-03-18 16:31:54 +00:00
|
|
|
url: `${STEAM_BASE_URL}/ISteamApps/GetAppList/v2`,
|
2021-10-04 20:59:54 +00:00
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
2022-02-26 01:49:00 +00:00
|
|
|
Accept: 'application/json',
|
2021-10-04 20:59:54 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => res.status(200).send(data))
|
2022-02-26 01:49:00 +00:00
|
|
|
.catch(error => res.send(error));
|
2021-10-04 20:59:54 +00:00
|
|
|
});
|