Skip to content

Commit

Permalink
Added the start of a sports endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ageddesi committed Aug 24, 2022
1 parent a852117 commit 853bb62
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 4 deletions.
1 change: 1 addition & 0 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 1 addition & 3 deletions modules/animal/utils/getSpeciesOfAnimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ const getSpeciesOfAnimal = (type: AnimalType, qty: number) : string[] => {
}
}

// Remove Duplications

return [...new Set(speciesList)];
return speciesList;

}

Expand Down
12 changes: 12 additions & 0 deletions modules/sports/api/sports-routes.ts
Original file line number Diff line number Diff line change
@@ -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)
})

}
124 changes: 124 additions & 0 deletions modules/sports/data/football-premier-league-2022.ts
Original file line number Diff line number Diff line change
@@ -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;
32 changes: 31 additions & 1 deletion swagger.json
Original file line number Diff line number Diff line change
@@ -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/"
},
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 853bb62

Please sign in to comment.