soccer-go
Version:
Soccer CLI for stats and results.
50 lines (49 loc) • 2.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLeagueByCode = exports.getLeagueByName = exports.leagueCodes = void 0;
const errors_1 = require("../utils/errors");
// TIER_ONE leagues are free, TIER_TWO requires paid API subscription
// Leagues from TIER_THREE and TIER_FOUR are not supported yet
exports.leagueCodes = [
// TIER_ONE - Free (12 leagues)
{ code: 'PL', name: 'Premier League', type: 'LEAGUE', tier: 'FREE' },
{ code: 'ELC', name: 'Championship', type: 'LEAGUE', tier: 'FREE' },
{ code: 'PD', name: 'Primera Division', type: 'LEAGUE', tier: 'FREE' },
{ code: 'BL1', name: 'Bundesliga', type: 'LEAGUE', tier: 'FREE' },
{ code: 'SA', name: 'Serie A', type: 'LEAGUE', tier: 'FREE' },
{ code: 'FL1', name: 'Ligue 1', type: 'LEAGUE', tier: 'FREE' },
{ code: 'DED', name: 'Eredivisie', type: 'LEAGUE', tier: 'FREE' },
{ code: 'PPL', name: 'Primeira Liga', type: 'LEAGUE', tier: 'FREE' },
{ code: 'BSA', name: 'Brasileiro Serie A', type: 'LEAGUE', tier: 'FREE' },
{ code: 'CL', name: 'Champions League', type: 'CUP', tier: 'FREE' },
{ code: 'WC', name: 'World Cup', type: 'CUP', tier: 'FREE' },
{ code: 'EC', name: 'European Championship', type: 'CUP', tier: 'FREE' },
// TIER_TWO - Paid (requires API subscription upgrade)
{ code: 'BL2', name: '2. Bundesliga', type: 'LEAGUE', tier: 'PAID' },
{ code: 'DFB', name: 'DFB-Pokal', type: 'CUP', tier: 'PAID' },
{ code: 'EL1', name: 'League One', type: 'LEAGUE', tier: 'PAID' },
{ code: 'FAC', name: 'FA Cup', type: 'CUP', tier: 'PAID' },
{ code: 'SB', name: 'Serie B', type: 'LEAGUE', tier: 'PAID' },
{ code: 'SD', name: 'Segunda Division', type: 'LEAGUE', tier: 'PAID' },
{ code: 'FL2', name: 'Ligue 2', type: 'LEAGUE', tier: 'PAID' },
{ code: 'EL', name: 'Europa League', type: 'CUP', tier: 'PAID' },
{ code: 'CLQ', name: 'Champions League Qualification', type: 'CUP', tier: 'PAID' },
{ code: 'MLS', name: 'MLS', type: 'LEAGUE', tier: 'PAID' },
{ code: 'ECF', name: "UEFA Women's Euro", type: 'CUP', tier: 'PAID' },
];
const getLeagueByName = (name) => {
const candidate = exports.leagueCodes.find((l) => l.name === name);
if (candidate) {
return candidate;
}
throw new errors_1.ApplicationError(errors_1.ErrorCode.LEAGUE_NOT_FOUND_BY_NAME, name);
};
exports.getLeagueByName = getLeagueByName;
const getLeagueByCode = (code) => {
const candidate = exports.leagueCodes.find((l) => l.code === code);
if (candidate) {
return candidate;
}
throw new errors_1.ApplicationError(errors_1.ErrorCode.LEAGUE_NOT_FOUND_BY_CODE, code);
};
exports.getLeagueByCode = getLeagueByCode;