diff --git a/.env.example b/.env.example index a75e1b19..e41373f1 100755 --- a/.env.example +++ b/.env.example @@ -3,7 +3,6 @@ HOST=http://localhost:3000 API_URL=https://api.test.faforever.com OAUTH_URL=https://hydra.test.faforever.com WP_URL=https://direct.faforever.com -LOBBY_API_URL=http://lobby.faforever.com:4000 CALLBACK=auth OAUTH_CLIENT_ID=faf-website OAUTH_CLIENT_SECRET=banana diff --git a/.env.faf-stack b/.env.faf-stack index 01e76dfb..4404ce8d 100644 --- a/.env.faf-stack +++ b/.env.faf-stack @@ -21,8 +21,6 @@ OAUTH_PUBLIC_URL=http://localhost:4444 # unsing the "production" wordpress because the faf-local-stack is just an empty instance without any news etc. WP_URL=https://direct.faforever.com -LOBBY_API_URL=http://faf-python-server:4000 - OAUTH_CLIENT_ID=faf-website OAUTH_CLIENT_SECRET=banana SESSION_SECRET_KEY=banana diff --git a/README.md b/README.md index 8b00ef7e..813ba768 100755 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Local requirements: - docker - docker compose -The website has dependencies to Hydra, [Lobby](https://github.com/FAForever/server), Wordpress and the [Java-API](https://github.com/FAForever/faf-java-api). +The website has dependencies to Hydra, Wordpress and the [Java-API](https://github.com/FAForever/faf-java-api). You can run those with the [local-stack](https://github.com/FAForever/faf-stack). If you got the [local-stack](https://github.com/FAForever/faf-stack) up and running, we need to stop the "faf-website" and replace it with a development container. diff --git a/express.js b/express.js index 931a86ac..3ad756c9 100644 --- a/express.js +++ b/express.js @@ -201,7 +201,6 @@ app.get('/account/connect', loggedIn, require(routes + 'account/get/connectSteam //app.get('/account/connectSteam', loggedIn, require(routes + 'account/get/connectSteam')); app.get('/account/resync', loggedIn, require(routes + 'account/get/resync')); // Not Protected -app.get('/lobby_api', cors(), require('./routes/lobby_api')); app.get('/account/create', require(routes + 'account/get/createAccount')); app.get('/account_activated', require(routes + 'account/get/register')); app.get('/account/register', require(routes + 'account/get/register')); diff --git a/routes/lobby_api.js b/routes/lobby_api.js deleted file mode 100644 index 38d80e3d..00000000 --- a/routes/lobby_api.js +++ /dev/null @@ -1,65 +0,0 @@ -const request = require("request"); -const cache = {}; -let isFetching = false; - -const PLAYER_COUNT_INTERVAL = process.env.PLAYER_COUNT_INTERVAL * 1000; - -exports = module.exports = function (req, res) { - let resource = req.query.resource; - if (cache[resource]) { - if (isFetching || Date.now() - cache[resource].pollTime < PLAYER_COUNT_INTERVAL) { - return res.send(cache[resource].data); - } - } - isFetching = true; - let queryResource = resource; - if (resource === "countries") { - queryResource = "players"; - } else if (resource === "lobby") { - queryResource = "games"; - } - request(process.env.LOBBY_API_URL + "/" + queryResource, function (error, response, body) { - let data = []; - - if (body) { - data = JSON.parse(body); - } else { - console.error( - "Error occured during parsing: ", - process.env.LOBBY_API_URL + "/" + resource, - "body: ", body, - "error: ", error, - "response", response - ); - } - - - if (resource === "lobby") { - cache[resource] = { - pollTime: Date.now(), - data: body - }; - } else if (resource === "countries") { - data = data.map(player => player.country); - const mapData = {}; - data.forEach(value => { - if (mapData[value] !== undefined) { - mapData[value] = mapData[value] + 1; - } else { - mapData[value] = 1; - } - }); - cache["countries"] = { - pollTime: Date.now(), - data: mapData - }; - } else { - cache[queryResource] = { - pollTime: Date.now(), - data: data.length.toString() - }; - } - isFetching = false; - return res.send(cache[resource].data); - }); -};