Sharing in case others find it useful
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Load HEVY_API_KEY from .env

+41 -17
+1
.env.sample
··· 1 + HEVY_API_KEY=your_api_key_here
+1
.gitignore
··· 1 1 WorkoutExport.csv 2 + .env
+22 -14
README.md
··· 10 10 11 11 ## Setup 12 12 13 - Add your Hevy API key to [config.tsm](config.tsm): 13 + Copy the sample env file and add your Hevy API key: 14 14 15 - ```ts 16 - export const HEVY_API_KEY = 'your-key-here'; 15 + ```sh 16 + cp .env.sample .env 17 + ``` 18 + 19 + Then edit `.env`: 20 + 21 + ``` 22 + HEVY_API_KEY=your_api_key_here 17 23 ``` 18 24 19 25 ## Workflow 20 26 21 27 ### Step 1 — Generate the exercise map template 22 28 23 - Reads your CSV and outputs a `exercise-map.tsm` file listing every unique exercise name: 29 + Reads your CSV and outputs an `exercise-map.ts` file listing every unique exercise name: 24 30 25 31 ```sh 26 - deno run --allow-read generate-map.tsm 32 + deno task generate-map 27 33 ``` 28 34 29 35 ### Step 2 — Get your Hevy exercise template IDs ··· 31 37 Fetches all exercise templates from your Hevy account and prints them as mappable key/value pairs: 32 38 33 39 ```sh 34 - deno run --allow-net get-templates.tsm 40 + deno task get-templates 35 41 ``` 36 42 37 43 ### Step 3 — Fill in the exercise map 38 44 39 - Open `exercise-map.tsm` and paste in the Hevy template ID for each exercise. Any exercise left as an empty string will be skipped during import. 45 + Open `exercise-map.ts` and paste in the Hevy template ID for each exercise. Any exercise left as an empty string will be skipped during import. 40 46 41 47 ```ts 42 48 export const EXERCISE_MAP: Record<string, string> = { ··· 49 55 ### Step 4 — Run the import 50 56 51 57 ```sh 52 - deno run --allow-read --allow-net import.tsm 58 + deno task import 53 59 ``` 54 60 55 61 Workouts are sent one day at a time with a 1.5-second delay between requests to respect Hevy's rate limits. Exercises not found in the map are skipped with a warning. ··· 58 64 59 65 | File | Purpose | 60 66 |------|---------| 61 - | `config.tsm` | API key, CSV path, API base URL | 62 - | `generate-map.tsm` | Generates `exercise-map.tsm` from the CSV | 63 - | `get-templates.tsm` | Lists Hevy exercise templates and their IDs | 64 - | `exercise-map.tsm` | Maps Fitbod exercise names → Hevy template IDs | 65 - | `import.tsm` | Main import script | 66 - | `WorkoutExport.csv` | Your Fitbod data export | 67 + | `.env` | Your Hevy API key (not committed) | 68 + | `.env.sample` | Template for `.env` | 69 + | `config.ts` | Loads env vars, CSV path, API base URL | 70 + | `generate-map.ts` | Generates `exercise-map.ts` from the CSV | 71 + | `get-templates.ts` | Lists Hevy exercise templates and their IDs | 72 + | `exercise-map.ts` | Maps Fitbod exercise names → Hevy template IDs | 73 + | `import.ts` | Main import script | 74 + | `WorkoutExport.csv` | Your Fitbod data export (not committed) |
+5 -2
config.ts
··· 1 - // config.tsm 1 + // config.ts 2 + import { load } from "jsr:@std/dotenv"; 3 + 4 + const env = await load(); 2 5 3 6 export const FITBOD_CSV_PATH = 'WorkoutExport.csv'; 4 - export const HEVY_API_KEY = 'YOUR_HEVY_API_KEY_HERE'; 7 + export const HEVY_API_KEY = env['HEVY_API_KEY'] ?? ''; 5 8 export const HEVY_API_BASE = 'https://api.hevyapp.com/v1';
+1 -1
deno.json
··· 1 1 { 2 2 "tasks": { 3 3 "generate-map": "deno run --allow-read --allow-write generate-map.ts", 4 - "get-templates": "deno run --allow-net get-templates.ts", 4 + "get-templates": "deno run --allow-read --allow-net get-templates.ts", 5 5 "import": "deno run --allow-read --allow-net import.ts" 6 6 } 7 7 }
+11
deno.lock
··· 1 + { 2 + "version": "5", 3 + "specifiers": { 4 + "jsr:@std/dotenv@*": "0.225.6" 5 + }, 6 + "jsr": { 7 + "@std/dotenv@0.225.6": { 8 + "integrity": "1d6f9db72f565bd26790fa034c26e45ecb260b5245417be76c2279e5734c421b" 9 + } 10 + } 11 + }