diff --git a/app.ts b/app.ts index ac1365eb..283f995c 100644 --- a/app.ts +++ b/app.ts @@ -10,6 +10,7 @@ require('./modules/animal/api/animal-routes')(app) // Animals require('./modules/countries/api/countries-routes')(app); // Countries require('./modules/images/api/images-routes')(app); // Images require('./modules/names/api/names-routes')(app); // Names +require('./modules/sports/api/sports-routes')(app); // Sports // Add an healthcheck endpoint app.get('/status', (req, res) => { diff --git a/modules/animal/utils/getSpeciesOfAnimal.ts b/modules/animal/utils/getSpeciesOfAnimal.ts index b5d5784b..07a168f6 100644 --- a/modules/animal/utils/getSpeciesOfAnimal.ts +++ b/modules/animal/utils/getSpeciesOfAnimal.ts @@ -54,9 +54,7 @@ const getSpeciesOfAnimal = (type: AnimalType, qty: number) : string[] => { } } - // Remove Duplications - - return [...new Set(speciesList)]; + return speciesList; } diff --git a/modules/sports/api/sports-routes.ts b/modules/sports/api/sports-routes.ts new file mode 100644 index 00000000..8477b642 --- /dev/null +++ b/modules/sports/api/sports-routes.ts @@ -0,0 +1,12 @@ +import { Request, Response } from 'express'; +import * as core from 'express-serve-static-core'; +import PremierLeagueData2022 from "../data/football-premier-league-2022"; + +module.exports = function(app: core.Express){ + + // Get a list of teams in the uk premier football league from 2022 + app.get("/sports/football/leagues/premier/teams", (req: Request, res: Response) => { + res.json(PremierLeagueData2022) + }) + +} \ No newline at end of file diff --git a/modules/sports/data/football-premier-league-2022.ts b/modules/sports/data/football-premier-league-2022.ts new file mode 100644 index 00000000..1bac167d --- /dev/null +++ b/modules/sports/data/football-premier-league-2022.ts @@ -0,0 +1,124 @@ +const PremierLeagueData2022 = [ + { + teamName: "Arsenal", + location: "London (Holloway)", + stadium: "Emirates Stadium", + capacity: "60,704" + }, + { + teamName: "Aston Villa", + location: "Birmingham", + stadium: "Villa Park", + capacity: "42,657" + }, + { + teamName: "Bournemouth", + location: "Bournemouth", + stadium: "Dean Court", + capacity: "11,307" + }, + { + teamName: "Brentford", + location: "London (Brentford)", + stadium: "Gtech Community Stadium ", + capacity: "17,250" + }, + { + teamName: "Brighton & Hove Albion", + location: "Falmer", + stadium: "Falmer Stadium", + capacity: "31,800" + }, + { + teamName: "Chelsea", + location: "London (Fulham)", + stadium: "Stamford Bridge", + capacity: "40,343" + }, + { + teamName: "Crystal Palace", + location: "London (Selhurst)", + stadium: "Selhurst Park", + capacity: "25,486" + }, + { + teamName: "Everton", + location: "Liverpool (Walton)", + stadium: "Goodison Park", + capacity: "39,414" + }, + { + teamName: "Fulham", + location: "London (Fulham)", + stadium: "Craven Cottage", + capacity: "22,384" + }, + { + teamName: "Leeds United", + location: "Leeds", + stadium: "Elland Road", + capacity: "37,608" + }, + { + teamName: "Leicester City", + location: "Leicester", + stadium: "King Power Stadium", + capacity: "32,262" + }, + { + teamName: "Liverpool", + location: "Liverpool (Anfield)", + stadium: "Anfield", + capacity: "53,394" + }, + { + teamName: "Manchester City", + location: "Manchester", + stadium: "City of Manchester Stadium", + capacity: "53,400" + }, + { + teamName: "Manchester United", + location: "Stretford", + stadium: "Old Trafford", + capacity: "74,310" + }, + { + teamName: "Newcastle United", + location: "Newcastle upon Tyne", + stadium: "St James' Park", + capacity: "52,305" + }, + { + teamName: "Nottingham Forest", + location: "West Bridgford", + stadium: "City Ground", + capacity: "30,332" + }, + { + teamName: "Southampton", + location: "Southampton", + stadium: "St Mary's Stadium", + capacity: "32,384" + }, + { + teamName: "Tottenham Hotspur", + location: "London (Tottenham)", + stadium: "Tottenham Hotspur Stadium", + capacity: "62,850" + }, + { + teamName: "West Ham United", + location: "London (Stratford)", + stadium: "London Stadium", + capacity: "62,500" + }, + { + teamName: "Wolverhampton Wanderers", + location: "Wolverhampton", + stadium: "Molineux Stadium", + capacity: "31,750" + } +] + +export default PremierLeagueData2022; \ No newline at end of file diff --git a/swagger.json b/swagger.json index df0c8658..9cfbe04a 100644 --- a/swagger.json +++ b/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "0.5.0", + "version": "0.6.0", "title": "Mocked-API", "description": "An API library for providing endpoints of mock data for use during testing. This API is still in the development and until it reaches version 1.0.0 the API is subject to change. To find out more head over to https://mocked-api.dev/" }, @@ -26,6 +26,10 @@ { "name": "Names", "description": "A set of endpoints to get randomly generated names" + }, + { + "name": "Sports", + "description": "A set of endpoints to get random sports data" } ], "paths": { @@ -1383,6 +1387,32 @@ } } } + }, + "/sports/football/leagues/premier/teams" : { + "get": { + "tags": ["Sports"], + "summary" : "Get a list of teams in the uk premier football league from 2022", + "parameters": [ + { + "in": "path", + "name": "qty", + "default": 10, + "description": "The amount of results you would like returned" + } + ], + "responses": { + "200" : { + "description" : "OK", + "schema": { + "type" : "array", + "items": { + "type" : "object", + "example": "{ teamName: '', location: '', stadium: '', capacity: ''}" + } + } + } + } + } } }, "definitions": {