Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
Convert full.js to typescript and fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyst committed Nov 30, 2022
1 parent 347d541 commit b9b9487
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/full.js → src/full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "" };
}
Expand Down
8 changes: 3 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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);
Expand Down

0 comments on commit b9b9487

Please sign in to comment.