diff --git a/src/modules/sports/api/sports-routes.ts b/src/modules/sports/api/sports-routes.ts index 552d0c16..bd10b5c3 100644 --- a/src/modules/sports/api/sports-routes.ts +++ b/src/modules/sports/api/sports-routes.ts @@ -5,7 +5,8 @@ import { getRandomSubArray } from '../../../utils/arrays'; import PremierLeagueData2022 from '../data/football-premier-league-2022'; import LaLigaLeagueData2022 from '../data/football-laliga-league-2022'; import SerieALeagueData2022 from '../data/football-serie-a-league-2022'; -import BasketballNbaLeague2022 from '../data/basketball-nba-league-2022' +import BasketballNbaLeague2022 from '../data/basketball-nba-league-2022'; +import Ligue1LeagueData2022 from '../data/football-ligue-1-league-2022'; module.exports = function (app: core.Express) { @@ -114,4 +115,31 @@ module.exports = function (app: core.Express) { const qty = getQtyFromRequest(req); res.json(getRandomSubArray(SerieALeagueData2022, qty)); }); + + /** + * @openapi + * '/sports/football/leagues/ligue1/teams/{qty}': + * get: + * tags: + * - Sports + * summary: Get a list of teams in the Ligue 1 (France) football league from 2022 + * parameters: + * - in: path + * name: qty + * description: The amount of results you would like returned + * default: 10 + * type: number + * responses: + * '200': + * description: OK + * schema: + * type: array + * items: + * type: object + * example: { teamName: '', location: '', stadium: '', capacity: ''} + */ + app.get('/sports/football/leagues/ligue1/teams/:qty?', (req: Request, res: Response) => { + const qty = getQtyFromRequest(req); + res.json(getRandomSubArray(Ligue1LeagueData2022, qty)); + }); }; diff --git a/src/modules/sports/data/football-ligue-1-league-2022.ts b/src/modules/sports/data/football-ligue-1-league-2022.ts new file mode 100644 index 00000000..6a6b8932 --- /dev/null +++ b/src/modules/sports/data/football-ligue-1-league-2022.ts @@ -0,0 +1,125 @@ +const Ligue1LeagueData2022 = [ + { + "teamName": "Ajaccio", + "location": "Ajaccio", + "stadium": "Stade François Coty", + "capacity": "10,446" + }, + { + "teamName": "Angers", + "location": "Angers", + "stadium": "Stade Raymond Kopa", + "capacity": "18,752" + }, + { + "teamName": "Auxerre", + "location": "Auxerre", + "stadium": "Stade de l'Abbé-Deschamps", + "capacity": "21,379" + }, + { + "teamName": "Brest", + "location": "Brest", + "stadium": "Stade Francis-Le Blé", + "capacity": "15,931" + }, + { + "teamName": "Clermont", + "location": "Clermont-Ferrand", + "stadium": "Stade Gabriel Montpied", + "capacity": "11,980" + }, + { + "teamName": "Lens", + "location": "Lens", + "stadium": "Stade Bollaert-Delelis", + "capacity": "37,705" + }, + { + "teamName": "Lille", + "location": "Lille", + "stadium": "Decathlon Arena Pierre Mauroy Stadium", + "capacity": "50,186" + }, + { + "teamName": "Lorient", + "location": "Lorient", + "stadium": "Stade du Moustoir", + "capacity": "18,890" + }, + { + "teamName": "Lyon", + "location": "Lyon", + "stadium": "Groupama Stadium", + "capacity": "59,186" + }, + { + "teamName": "Marseille", + "location": "Marseille", + "stadium": "Orange Vélodrome", + "capacity": "67,394" + }, + { + "teamName": "Monaco", + "location": " Monaco", + "stadium": "Stade Louis II", + "capacity": "18,523" + }, + { + "teamName": "Montpellier", + "location": "Montpellier", + "stadium": "Stade de la Mosson", + "capacity": "32,900" + }, + { + "teamName": "Nantes", + "location": "Nantes", + "stadium": "Stade de la Beaujoire", + "capacity": "35,322" + }, + { + "teamName": "Nice", + "location": "Nice", + "stadium": "Allianz Riviera", + "capacity": "35,624" + }, + { + "teamName": "Paris Saint-Germain", + "location": "Paris", + "stadium": "Parc des Princes", + "capacity": "48,583" + }, + { + "teamName": "Reims", + "location": "Reims", + "stadium": "Stade Auguste Delaune", + "capacity": "21,684" + }, + { + "teamName": "Rennes", + "location": "Rennes", + "stadium": "Roazhon Park", + "capacity": "29,778" + }, + { + "teamName": "Strasbourg", + "location": "Strasbourg", + "stadium": "Stade de la Meinau", + "capacity": "29,230" + }, + { + "teamName": "Toulouse", + "location": "Toulouse", + "stadium": "Stadium Municipal", + "capacity": "33,150" + }, + { + "teamName": "Troyes", + "location": "Troyes", + "stadium": "Stade de l'Aube", + "capacity": "21,684" + } + ] +; + +export default Ligue1LeagueData2022; diff --git a/src/modules/sports/tests/api/sports-routes.test.ts b/src/modules/sports/tests/api/sports-routes.test.ts index bc112935..ffd5c48c 100644 --- a/src/modules/sports/tests/api/sports-routes.test.ts +++ b/src/modules/sports/tests/api/sports-routes.test.ts @@ -44,4 +44,20 @@ describe('sports api endpoints', () => { expect(response.body.length).toBe(qty); }); }); + + describe('GET /sports/football/leagues/ligue1/teams', () => { + it('should return a list of ligue 1 teams', async () => { + const qty = 5; + const response = await request(app).get(`/sports/football/leagues/ligue1/teams/${qty}`); + + expect(response.body.length).toBe(qty); + }); + + it('no quantity specified should return a list of 10 ligue 1 teams', async () => { + const defaultNumber = 10; + const response = await request(app).get(`/sports/football/leagues/ligue1/teams`); + + expect(response.body.length).toBe(defaultNumber); + }); + }); });