From b9b948726fca3b692aeb5f8df7ce6ea7692cc730 Mon Sep 17 00:00:00 2001 From: Rhys Tyers Date: Wed, 30 Nov 2022 22:13:27 +0000 Subject: [PATCH] Convert full.js to typescript and fix type errors --- src/{full.js => full.ts} | 4 +++- src/index.ts | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/{full.js => full.ts} (95%) diff --git a/src/full.js b/src/full.ts similarity index 95% rename from src/full.js rename to src/full.ts index b8ed60e..44c8677 100644 --- a/src/full.js +++ b/src/full.ts @@ -8,7 +8,9 @@ const tokenRe = /.*csrf-token.*content="(.*)"/; const config = require("./config.js"); -export default async (activityId) => { +export default async ( + activityId: number +): Promise<{ gpx: string | null; notes: string }> => { if (!config.athleteEmail || !config.athletePassword) { return { gpx: null, notes: "" }; } diff --git a/src/index.ts b/src/index.ts index 9f46486..07fefb6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,7 +117,7 @@ export default function registerEndpoint(router, { services, getSchema, database return next(); }); - const getActivity = async (req, activityId, body = null) => { + const getActivity = async (req, activityId) => { const schema = await getSchema(); const rowService = new ItemsService(config.collection, { schema }); const filesService = new FilesService({ schema }); @@ -138,13 +138,11 @@ export default function registerEndpoint(router, { services, getSchema, database const fileKey = hydratedResult?.files?.[0]?.directus_files_id?.id || undefined; // Get Activity - if (!body) { - const token = req.strava_token; - const data = (await got( + const token = req.strava_token; + const data = (await got( `https://www.strava.com/api/v3/activities/${activityId}`, { headers: { Authorization: `Bearer ${token.access_token}` } } ).json()) as StravaActivity; - } // Get things not available in the API const { gpx, notes } = await getFull(activityId);