Skip to content

Commit 603bb2c

Browse files
committed
feat: update handball
1 parent 2a1b0fd commit 603bb2c

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

functions/src/graphql/swisshandball/resolvers.ts

+10-16
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import {defineSecret} from 'firebase-functions/params';
1313
import {onInit} from 'firebase-functions/v2/core';
1414
import {SecretParam} from 'firebase-functions/lib/params/types.js';
1515

16-
1716
let swisshandballToken: SecretParam | undefined;
18-
onInit(() => {
19-
swisshandballToken = defineSecret('SWISSHANDBALL_TOKEN');
20-
});
2117

2218
export default {
2319

@@ -87,6 +83,7 @@ async function getTeams(clubId: string) {
8783
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
8884
});
8985
if (swisshandballToken) {
86+
logger.info('>> https://clubapi.handball.ch/rest/v1/clubs/' + clubId + '/teams');
9087
// const swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');;
9188
// eslint-disable-next-line no-undef
9289
const data = await fetch('https://clubapi.handball.ch/rest/v1/clubs/' + clubId + '/teams', {
@@ -125,6 +122,7 @@ async function getTeam(teamId: string, clubId: string) {
125122
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
126123
});
127124
if (swisshandballToken) {
125+
logger.info('>> https://clubapi.handball.ch/rest/v1/teams/' + teamId);
128126
// eslint-disable-next-line no-undef
129127
const data = await fetch('https://clubapi.handball.ch/rest/v1/teams/' + teamId, {
130128
headers: {'Authorization': 'Basic ' + swisshandballToken?.value() || ''},
@@ -168,10 +166,9 @@ async function getClubs() {
168166
}
169167

170168
async function getClub(clubId: string) {
171-
onInit(() => {
172-
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
173-
});
169+
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
174170
if (swisshandballToken) {
171+
logger.info('>> https://clubapi.handball.ch/rest/v1/clubs/' + clubId);
175172
// eslint-disable-next-line no-undef
176173
const data = await fetch('https://clubapi.handball.ch/rest/v1/clubs/' + clubId, {
177174
headers: {'Authorization': 'Basic ' + swisshandballToken?.value() || ''},
@@ -198,10 +195,9 @@ async function getClub(clubId: string) {
198195

199196
async function getClubGames(clubId: string) {
200197
const gameList = <any>[];
201-
onInit(() => {
202-
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
203-
});
198+
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
204199
if (swisshandballToken) {
200+
logger.info('>> https://clubapi.handball.ch/rest/v1/clubs/' + clubId + '/games');
205201
// eslint-disable-next-line no-undef
206202
const data = await fetch('https://clubapi.handball.ch/rest/v1/clubs/' + clubId + '/games', {
207203
headers: {'Authorization': 'Basic ' + swisshandballToken?.value() || ''},
@@ -267,10 +263,9 @@ async function getClubGames(clubId: string) {
267263

268264
async function getGames(teamId: string, clubId: string) {
269265
const gameList = <any>[];
270-
onInit(() => {
271-
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
272-
});
266+
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
273267
if (swisshandballToken) {
268+
logger.info('>> https://clubapi.handball.ch/rest/v1/teams/' + teamId + '/games');
274269
// eslint-disable-next-line no-undef
275270
const data = await fetch('https://clubapi.handball.ch/rest/v1/teams/' + teamId + '/games', {
276271
headers: {'Authorization': 'Basic ' + swisshandballToken?.value() || ''},
@@ -336,10 +331,9 @@ async function getGames(teamId: string, clubId: string) {
336331

337332
async function getRankings(teamId: string, clubId: string) {
338333
const rankingList = <any>[];
339-
onInit(() => {
340-
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
341-
});
334+
swisshandballToken = defineSecret('SWISSHANDBALL_SH_' + clubId + '_TOKEN');
342335
if (swisshandballToken) {
336+
logger.info('>> https://clubapi.handball.ch/rest/v1/teams/' + teamId + '/group');
343337
// eslint-disable-next-line no-undef
344338
const data = await fetch('https://clubapi.handball.ch/rest/v1/teams/' + teamId + '/group', {
345339
headers: {'Authorization': 'Basic ' + swisshandballToken?.value() || ''},

functions/src/graphql/swissvolley/resolvers.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ async function getClubs() {
220220
}
221221
async function getGames(teamId: string) {
222222
const gameList = < any > [];
223+
swissvolleyToken = defineSecret('SWISSVOLLEY_TOKEN');
224+
logger.info('>> https://api.volleyball.ch/indoor/games?teamId=' + teamId + '&includeCup=1');
223225

224226
// eslint-disable-next-line no-undef
225227
const data = await fetch('https://api.volleyball.ch/indoor/games?teamId=' + teamId + '&includeCup=1', { // region=SVRNO& not needed
@@ -246,7 +248,8 @@ async function getGame(gameId: string) {
246248

247249
async function getRankings(groupId: string) {
248250
// https://api.volleyball.ch/indoor/ranking/24319
249-
251+
swissvolleyToken = defineSecret('SWISSVOLLEY_TOKEN');
252+
logger.info('>> https://api.volleyball.ch/indoor/ranking/' + groupId);
250253
// eslint-disable-next-line no-undef
251254
const data = await fetch('https://api.volleyball.ch/indoor/ranking/' + groupId, {
252255
headers: {

0 commit comments

Comments
 (0)