Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge remote-tracking branch 'origin' into feature/game-category-filter
- Loading branch information
Showing
71 changed files
with
4,664 additions
and
1,984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
#!/bin/sh | ||
|
||
echo "running the 'pre-commit' script" | ||
|
||
echo "running eslint..." | ||
./node_modules/.bin/eslint . | ||
|
||
echo "running tests..." | ||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,4 +3,7 @@ node_modules/ | ||
coverage/ | ||
*.db | ||
screenshots/* | ||
docs/ | ||
docs/ | ||
|
||
# ignore uploaded user images | ||
public/images/upload_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* eslint-disable max-statements */ | ||
/* eslint-disable max-lines-per-function */ | ||
/* eslint-disable complexity */ | ||
'use strict' | ||
|
||
const request = require('request') | ||
const path = require('path') | ||
const Game = require(path.join(__dirname, '/../models/game')) | ||
const db = require(path.join(__dirname, '/../db')) | ||
const dbctx = new db.SqliteDbContext(path.join(__dirname, '/../app.db')) | ||
|
||
//Automatically inserted data | ||
request('https://api.steampowered.com/ISteamApps/GetAppList/v2/', async(error, response, body) => { | ||
const allGames = JSON.parse(body) | ||
let i = 1 | ||
const gameAmount = 200 //change according to how many games you want to add | ||
for(i; i<gameAmount; i++) { | ||
const gameid = allGames.applist.apps[i].appid //getting the appID to insert into next URL as a string | ||
gameid.toString() | ||
request(`https://store.steampowered.com/api/appdetails/?appids=${gameid}` , async(error, response, body) => { | ||
//console.log(gameid) | ||
const statusInt = 200 | ||
if (response.statusCode !== statusInt) { | ||
//if the api doesn't load the page, skip | ||
return | ||
} | ||
try { | ||
const gameObj = JSON.parse(body) | ||
if(gameObj[gameid].success === false) { | ||
//checking if it found the game | ||
return | ||
} | ||
if(!gameObj[gameid].data.hasOwnProperty('developers')) { | ||
//checking if the developer property exists | ||
return | ||
} | ||
if(!gameObj[gameid].data.hasOwnProperty('screenshots')) { | ||
//if game has no screenshots, skip | ||
return | ||
} | ||
const gameData = gameObj[gameid].data | ||
if(gameData.type !== 'game') { | ||
return | ||
} | ||
//Creating Game Object | ||
let game = new Game( | ||
gameData.name, | ||
gameData.short_description, | ||
gameData.about_the_game.replace(/<[^>]*>?/gm, ''), | ||
gameData.release_date.date, | ||
gameData.developers[0], //not every game has developers listed so it repeats the publisher | ||
gameData.publishers[0], | ||
1, | ||
'yes', | ||
gameData.header_image, | ||
gameData.screenshots[0].path_thumbnail) | ||
game.categories = [] | ||
let category | ||
for(let i=0; i<gameData.genres.length; i++) { | ||
gameData.genres[i].id = -1 | ||
gameData.genres[i].name = gameData.genres[i].description | ||
delete gameData.genres[i].description | ||
try{ | ||
category = await dbctx.createCategory(gameData.genres[i]) | ||
} catch(err) { | ||
category = await dbctx.getCategory(gameData.genres[i].name) | ||
} | ||
game.categories.push(category) | ||
} | ||
game = await dbctx.createGame(game) | ||
const pltfrm = 38 | ||
const platform = await dbctx.getPlatform(pltfrm) | ||
await dbctx.linkGamePlatform(game, platform) | ||
} catch(err) { | ||
throw new Error(`Game: https://store.steampowered.com/api/appdetails/?appids=${gameid} ${err}`) | ||
} | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
INSERT INTO `games` VALUES | ||
(1, | ||
'The Last of Us', | ||
'Hope is the key to survival.', | ||
'Set in the post-apocalyptic United States, the game tells the story of survivors Joel and Ellie as they work together to survive their westward journey across what remains of the country to find a possible cure for the modern fungal plague that has nearly decimated the entire human race.', | ||
'04/06/2013', | ||
'Naughty Dog', | ||
'Sony Computer Entertainment', | ||
1, | ||
'yes', | ||
'tlou.jpg', | ||
'tlousplash.jpg'); | ||
|
||
INSERT INTO `games` VALUES | ||
(2, | ||
'The Legend of Zelda: Breath of the Wild', | ||
'Step into a world of discovery, exploration and adventure.', | ||
'No kingdom. No memories. After a 100-year slumber, Link wakes up alone in a world he no longer remembers. Now the legendary hero must explore a vast and dangerous land and regain his memories before Hyrule is lost forever. Armed only with what he can scavenge, Link sets out to find answers and the resources needed to survive.', | ||
'03/03/2017', | ||
'Nintendo EPD', | ||
'Nintendo', | ||
2, | ||
'yes', | ||
'botw.jpg', | ||
'botwsplash.jpg'); | ||
|
||
INSERT INTO `games` VALUES | ||
(3, | ||
"Marvel's Spider-Man", | ||
'Be Greater.', | ||
'After eight years behind the mask, Peter Parker is a crime-fighting expert. Feel the full power of a more experienced Spider-Man with improvisational combat, dynamic acrobatics, fluid urban traversal, and environmental interactions. A rookie no longer, this is the most masterful Spider-Man you’ve ever played.', | ||
'07/09/2018', | ||
'Insomniac Games', | ||
'Sony Interactive Entertainment', | ||
2, | ||
'yes', | ||
'spiderman.jpg', | ||
'spidermansplash.jpg'); | ||
|
||
INSERT INTO `games` VALUES | ||
(4, | ||
"Football Manager 2020", | ||
'Your club, your way.', | ||
'Manage your football club, your way. Every decision counts in FM20 with new features rewarding planning and progression like never before, empowering managers to develop both your club’s and your own unique managerial identity.', | ||
'19/11/2019', | ||
'Sports Interactive', | ||
'SEGA', | ||
1, | ||
'yes', | ||
'fm20poster.jpg', | ||
'fm20splash.jpg'); | ||
|
||
INSERT INTO `games` VALUES | ||
(5, | ||
"Star Wars Jedi: Fallen Order", | ||
'Become a Jedi.', | ||
'The Empire seeks to eradicate all Jedi after the execution of Order 66. You, a Jedi Padawan-turned-fugitive, must fight for your survival as you explore the mysteries of a long-extinct civilization in hopes of rebuilding the Jedi Order.', | ||
'15/11/2019', | ||
'Respawn Entertainment', | ||
'Electronic Arts', | ||
2, | ||
'yes', | ||
'starwarsjfoposter.jpg', | ||
'starwarsjfosplash.jpg'); | ||
|
||
INSERT INTO `games` VALUES | ||
(6, | ||
"Minecraft", | ||
'Minecraft is a game about placing blocks and going on adventures.', | ||
'Explore randomly generated worlds and build amazing things from the simplest of homes to the grandest of castles. Play in creative mode with unlimited resources or mine deep into the world in survival mode, crafting weapons and armor to fend off the dangerous mobs.', | ||
'18/11/2011', | ||
'Mojang', | ||
'Mojang', | ||
2, | ||
'yes', | ||
'minecraft.jpg', | ||
'minecraftsplash.png'); | ||
|
||
INSERT INTO 'platforms' VALUES (1, 'Atari 2600'); | ||
INSERT INTO 'platforms' VALUES (2, 'Color TV-Game'); | ||
INSERT INTO 'platforms' VALUES (3, 'Magnavox Odyssey'); | ||
INSERT INTO 'platforms' VALUES (4, 'Intellivision'); | ||
INSERT INTO 'platforms' VALUES (5, 'Atari 5200'); | ||
INSERT INTO 'platforms' VALUES (6, 'ColecoVision'); | ||
INSERT INTO 'platforms' VALUES (7, 'Nintendo Entertainment System'); | ||
INSERT INTO 'platforms' VALUES (8, 'Master System'); | ||
INSERT INTO 'platforms' VALUES (9, 'TurboGrafx-16'); | ||
INSERT INTO 'platforms' VALUES (10, 'Sega Genesis'); | ||
INSERT INTO 'platforms' VALUES (11, 'Atari Lynx'); | ||
INSERT INTO 'platforms' VALUES (12, 'Game Boy'); | ||
INSERT INTO 'platforms' VALUES (13, 'SNES'); | ||
INSERT INTO 'platforms' VALUES (14, 'Sega Game Gear'); | ||
INSERT INTO 'platforms' VALUES (15, 'Philips CD-i'); | ||
INSERT INTO 'platforms' VALUES (16, 'Sega Pico'); | ||
INSERT INTO 'platforms' VALUES (17, 'Sega Saturn'); | ||
INSERT INTO 'platforms' VALUES (18, 'PlayStation'); | ||
INSERT INTO 'platforms' VALUES (19, 'Nintendo 64'); | ||
INSERT INTO 'platforms' VALUES (20, 'Dreamcast'); | ||
INSERT INTO 'platforms' VALUES (21, 'WonderSwan'); | ||
INSERT INTO 'platforms' VALUES (22, 'PlayStation 2'); | ||
INSERT INTO 'platforms' VALUES (23, 'Xbox'); | ||
INSERT INTO 'platforms' VALUES (24, 'Game Boy Advance'); | ||
INSERT INTO 'platforms' VALUES (25, 'GameCube'); | ||
INSERT INTO 'platforms' VALUES (26, 'N-Gage'); | ||
INSERT INTO 'platforms' VALUES (27, 'Nintendo DS'); | ||
INSERT INTO 'platforms' VALUES (28, 'PlayStation Portable'); | ||
INSERT INTO 'platforms' VALUES (29, 'Xbox 360'); | ||
INSERT INTO 'platforms' VALUES (30, 'Nintendo Wii'); | ||
INSERT INTO 'platforms' VALUES (31, 'PlayStation 3'); | ||
INSERT INTO 'platforms' VALUES (32, 'Nintendo 3DS '); | ||
INSERT INTO 'platforms' VALUES (33, 'PlayStation Vita'); | ||
INSERT INTO 'platforms' VALUES (34, 'Wii U'); | ||
INSERT INTO 'platforms' VALUES (35, 'Xbox One'); | ||
INSERT INTO 'platforms' VALUES (36, 'PlayStation 4'); | ||
INSERT INTO 'platforms' VALUES (37, 'Nintendo Switch'); | ||
INSERT INTO 'platforms' VALUES (38, 'Microsoft Windows'); | ||
INSERT INTO 'platforms' VALUES (39, 'macOS'); | ||
INSERT INTO 'platforms' VALUES (40, 'iOS'); | ||
INSERT INTO 'platforms' VALUES (41, 'Google Stadia'); | ||
INSERT INTO 'platforms' VALUES (42, 'Linux'); | ||
|
||
INSERT INTO 'categories' ('name') VALUES ('Action'); | ||
INSERT INTO 'categories' ('name') VALUES ('Platformer'); | ||
INSERT INTO 'categories' ('name') VALUES ('Shooter'); | ||
INSERT INTO 'categories' ('name') VALUES ('Fighting'); | ||
INSERT INTO 'categories' ('name') VALUES ('Stealth'); | ||
INSERT INTO 'categories' ('name') VALUES ('Survival'); | ||
INSERT INTO 'categories' ('name') VALUES ('Sandbox'); | ||
INSERT INTO 'categories' ('name') VALUES ('Rhythm'); | ||
INSERT INTO 'categories' ('name') VALUES ('Horror'); | ||
INSERT INTO 'categories' ('name') VALUES ('Visual Novel'); | ||
INSERT INTO 'categories' ('name') VALUES ('RPG'); | ||
INSERT INTO 'categories' ('name') VALUES ('MMORPG'); | ||
INSERT INTO 'categories' ('name') VALUES ('Action RPG'); | ||
INSERT INTO 'categories' ('name') VALUES ('Rougelike'); | ||
INSERT INTO 'categories' ('name') VALUES ('Tower Defence'); | ||
INSERT INTO 'categories' ('name') VALUES ('Racing'); | ||
INSERT INTO 'categories' ('name') VALUES ('Puzzle'); | ||
INSERT INTO 'categories' ('name') VALUES ('Indie'); | ||
INSERT INTO 'categories' ('name') VALUES ('Adventure'); | ||
INSERT INTO 'categories' ('name') VALUES ('Sports'); | ||
INSERT INTO 'categories' ('name') VALUES ('Simulation'); | ||
INSERT INTO 'categories' ('name') VALUES ('Stratgey'); | ||
INSERT INTO 'categories' ('name') VALUES ('Open World'); | ||
|
||
|
||
|
||
|
||
INSERT INTO | ||
`gamePlatforms` | ||
VALUES | ||
(1, 31), | ||
(1, 36), | ||
|
||
(2, 34), | ||
(2, 37), | ||
(3, 36), | ||
|
||
(4, 38), | ||
(4, 37), | ||
(4, 39), | ||
(4, 40), | ||
(4, 41), | ||
|
||
(5, 35), | ||
(5, 36), | ||
(5, 38), | ||
|
||
(6, 38), | ||
(6, 39), | ||
(6, 29), | ||
(6, 31), | ||
(6, 33), | ||
(6, 34), | ||
(6, 35), | ||
(6, 36), | ||
(6, 37), | ||
(6, 40), | ||
(6, 42); | ||
|
||
INSERT INTO | ||
`gameCategories` | ||
VALUES | ||
(1, 1), | ||
(1, 3), | ||
(1, 5), | ||
(1, 6), | ||
(1, 9), | ||
(2, 6), | ||
(2, 23), | ||
(2, 11), | ||
(2, 19), | ||
(3, 1), | ||
(3, 2), | ||
(3, 23), | ||
(4, 20), | ||
(4, 21), | ||
(4, 22), | ||
(5, 1), | ||
(5, 19), | ||
(6, 6), | ||
(6, 7), | ||
(6, 18), | ||
(6, 19); | ||
|
||
INSERT INTO `users` (`username`, `hash`, `isAdmin`) VALUES ('admin', '$2b$12$niVK8DnXKSyYzAIOUun2C.PZ51waVc2NU/e7DQ9cYM6zxNwUiiOCG', 'yes'); | ||
INSERT INTO `users` (`username`, `hash`, `isAdmin`) VALUES ('user', '$2b$12$niVK8DnXKSyYzAIOUun2C.PZ51waVc2NU/e7DQ9cYM6zxNwUiiOCG', 'no'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.