Skip to content

Commit

Permalink
chore: migrate from heroku to render.com (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
theDavidBarton committed Aug 28, 2022
1 parent d554757 commit 17ff1d0
Show file tree
Hide file tree
Showing 11 changed files with 2,349 additions and 2,053 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ on:
- master

jobs:
deploy-on-heroku:
deploy-on-render:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: Use Node.js 12.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x

- name: Yarn install BE
run: yarn
Expand All @@ -32,5 +32,5 @@ jobs:
yarn lint .
yarn test --watchAll=false --verbose
- name: Deploy to Heroku
run: echo "Follow deployment on Heroku https://dashboard.heroku.com/apps/retro-game-finder/activity"
- name: Deploy to Render.com
run: echo "Follow deployment on Heroku https://dashboard.render.com/"
5 changes: 3 additions & 2 deletions client/src/components/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import github from './../img/github.svg';
export default function Header() {
const [data, setData] = useState(null);
const [dataIsReady, setDataIsReady] = useState(false);
const domain = process.env.NODE_ENV === 'production' ? 'https://retro-game-finder-backend.onrender.com' : '';

const getRawgApi = useCallback(async () => {
try {
const response = await fetch('/api/topRatedRecommended');
const response = await fetch(`${domain}/api/topRatedRecommended`);
const json = await response.json();
setData(json);
setDataIsReady(true);
} catch (e) {
console.error(e);
}
}, []);
}, [domain]);

useEffect(() => {
getRawgApi();
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/homepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ export default function Homepage() {
{ id: 10, value: 9 }
]);

const domain = process.env.NODE_ENV === 'production' ? 'https://retro-game-finder-backend.onrender.com' : '';

const getRawgApi = useCallback(async () => {
try {
const response = await fetch('/api/trending');
const response = await fetch(`${domain}/api/trending`);
const json = await response.json();
setData(json);
setDataIsReady(true);
} catch (e) {
console.error(e);
}
}, []);
}, [domain]);

useEffect(() => {
getRawgApi();
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/homepageTrending.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import React, { useState, useEffect, Fragment, useCallback } from 'react';

export default function Trending({ data, value }) {
const [detailsData, setDetailsData] = useState(null);
const domain = process.env.NODE_ENV === 'production' ? 'https://retro-game-finder-backend.onrender.com' : '';

const getRawgApi = useCallback(async () => {
try {
const response = await fetch(`/api/videogame/${data.results[value].id}`);
const response = await fetch(`${domain}/api/videogame/${data.results[value].id}`);
const json = await response.json();
setDetailsData(json);
} catch (e) {
console.error(e);
}
}, [data, value]);
}, [data, value, domain]);

useEffect(() => {
getRawgApi();
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export default function Search() {
const [dropdownIsopened, setDropdownIsopened] = useState(false);
const [keyword, setKeyword] = useState('');

const domain = process.env.NODE_ENV === 'production' ? 'https://retro-game-finder-backend.onrender.com' : '';

useEffect(() => {
async function getRawgApi() {
if (keyword !== '') {
try {
const response = await fetch(`/api/videogameAutocomplete?q=${keyword.toLowerCase()}`);
const response = await fetch(`${domain}/api/videogameAutocomplete?q=${keyword.toLowerCase()}`);
const json = await response.json();
setData(json);
setDataIsReady(true);
Expand All @@ -21,7 +23,7 @@ export default function Search() {
}
}
getRawgApi();
}, [keyword]);
}, [keyword, domain]);

const setKeywordInInput = event => {
setKeyword(event.target.value);
Expand Down
13 changes: 7 additions & 6 deletions client/src/components/videogame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ export default function Videogame() {
const [oldgameshelfOfferAvailable, setOldgameshelfOfferAvailable] = useState(false);
const [snesnowIdentifier, setSnesnowIdentifier] = useState(null);
const [snesnowOfferAvailable, setSnesnowOfferAvailable] = useState(false);
const domain = process.env.NODE_ENV === 'production' ? 'https://retro-game-finder-backend.onrender.com' : '';

const getRawgApi = useCallback(async () => {
try {
// _RAWG game details call
const response = await fetch(`/api/videogame/${id}`);
const response = await fetch(`${domain}/api/videogame/${id}`);
const json = await response.json();
setData(json);
setDataIsReady(true);
} catch (e) {
console.error(e);
}
}, [id]);
}, [id, domain]);

useEffect(() => {
getRawgApi();
Expand All @@ -51,7 +52,7 @@ export default function Videogame() {
const yearValue = data.released ? data.released.match(/[0-9]{4}/) : null;

if (yearValue) {
const response = await fetch(`/api/searchArchive?title=${titleValue}&year=${yearValue}`);
const response = await fetch(`${domain}/api/searchArchive?title=${titleValue}&year=${yearValue}`);
const json = await response.json();
const identifier = json.response.docs.length > 0 ? json.response.docs[0].identifier : null;
if (identifier) {
Expand All @@ -71,7 +72,7 @@ export default function Videogame() {
return null;
});
if (isNES.length > 0) {
const response = await fetch(`/api/searchOldgameshelf?title=${titleValue}`);
const response = await fetch(`${domain}/api/searchOldgameshelf?title=${titleValue}`);
const json = await response.json();
if (json[0] !== undefined) {
setOldgameshelfIdentifier(`${json[0].slug}-${json[0].uid}`);
Expand All @@ -90,7 +91,7 @@ export default function Videogame() {
return null;
});
if (isSNES.length > 0) {
const response = await fetch(`/api/searchSnesnow?title=${titleValue}`);
const response = await fetch(`${domain}/api/searchSnesnow?title=${titleValue}`);
const json = await response.json();
if (json[0] !== undefined) {
setSnesnowIdentifier(`${json[0].slug}-${json[0].id}`);
Expand All @@ -101,7 +102,7 @@ export default function Videogame() {
console.error(e);
}
}
}, [data, dataIsReady]);
}, [data, dataIsReady, domain]);

useEffect(() => {
getArchiveApi();
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/videogameSimilarVideogames.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import Suggested from './videogameSuggested';

export default function SimilarVideogames({ data }) {
const [suggestedElements, setSuggestedElements] = useState(null);
const domain = process.env.NODE_ENV === 'production' ? 'https://retro-game-finder-backend.onrender.com' : '';
useEffect(() => {
async function getRawgApi() {
try {
const response = await fetch(`/api/videogameAutocomplete?q=${data.name}`);
const response = await fetch(`${domain}/api/videogameAutocomplete?q=${data.name}`);
const json = await response.json();
setSuggestedElements(json);
} catch (e) {
console.error(e);
}
}
getRawgApi();
}, [data]);
}, [data, domain]);

return (
<Fragment>
Expand Down

0 comments on commit 17ff1d0

Please sign in to comment.