UNPKG

f1-api-node

Version:

A simple library written in typescript to fetch Formula-1 data

97 lines 3.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fastestLaps = exports.raceSchedule = exports.raceResults = exports.worldChampions = exports.constructorStandings = exports.driverStandings = exports.teamLineUp = exports.driverLineUp = void 0; const driver_lineup_1 = require("../scraper/driver-lineup"); const team_lineup_1 = require("../scraper/team-lineup"); const driver_standings_1 = require("../scraper/driver-standings"); const constructors_standings_1 = require("../scraper/constructors-standings"); const world_champions_1 = require("../scraper/world-champions"); const race_results_1 = require("../scraper/race-results"); const race_schedule_1 = require("../scraper/race-schedule"); const fastest_laps_1 = require("../scraper/fastest-laps"); const driverLineUp = async (req, res) => { try { const data = await (0, driver_lineup_1.getDriverLineup)(); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.driverLineUp = driverLineUp; const teamLineUp = async (req, res) => { try { const data = await (0, team_lineup_1.getTeamLineup)(); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.teamLineUp = teamLineUp; const driverStandings = async (req, res) => { try { const { year } = req.params; const data = await (0, driver_standings_1.getDriverStandings)(parseInt(year)); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.driverStandings = driverStandings; const constructorStandings = async (req, res) => { try { const { year } = req.params; const data = await (0, constructors_standings_1.getConstructorStandings)(parseInt(year)); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.constructorStandings = constructorStandings; const worldChampions = async (req, res) => { try { const data = await (0, world_champions_1.getWorldChampions)(); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.worldChampions = worldChampions; const raceResults = async (req, res) => { try { const { year } = req.params; const data = await (0, race_results_1.getRaceResults)(parseInt(year)); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.raceResults = raceResults; const raceSchedule = async (req, res) => { try { const { year } = req.params; const data = await (0, race_schedule_1.getRaceSchedule)(parseInt(year)); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.raceSchedule = raceSchedule; const fastestLaps = async (req, res) => { try { const { year } = req.params; const data = await (0, fastest_laps_1.getFastestLaps)(parseInt(year)); res.json(data); } catch (err) { res.status(500).json({ error: err.message.toString() }); } }; exports.fastestLaps = fastestLaps; //# sourceMappingURL=endpoints-api.js.map