REST API for Pump workout tracker with Azure Table Storage backend and Shared Key authentication.
- Node.js 18+
- Azure Functions Core Tools:
npm install -g azure-functions-core-tools@4 - Azure Storage Account (or Azurite for local development)
- Install dependencies:
npm install- Configure
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AZURE_STORAGE_CONNECTION_STRING": "<your-connection-string>",
"API_SHARED_KEY": "<your-shared-key>"
}
}For local development with Azurite:
- Install Azurite:
npm install -g azurite - Start Azurite:
azurite --silent --location ./azurite --debug ./azurite/debug.log - Use connection string:
UseDevelopmentStorage=true
- Create tables in Azure Storage:
# Using Azure CLI
az storage table create --name routines --connection-string "<connection-string>"
az storage table create --name exercises --connection-string "<connection-string>"Start the Functions runtime:
npm startAPI runs at http://localhost:7071
All endpoints require x-api-key header with the shared key configured in API_SHARED_KEY.
Example:
curl -H "x-api-key: your-shared-key" \
"http://localhost:7071/api/routines?userId=user123"GET /api/routines?userId={userId}&startDate={YYYY-MM-DD}&endDate={YYYY-MM-DD}- List routinesPOST /api/routines?userId={userId}- Create routineGET /api/routines/{routineId}?userId={userId}- Get routinePATCH /api/routines/{routineId}?userId={userId}- Update routineDELETE /api/routines/{routineId}?userId={userId}- Delete routine
GET /api/exercises?userId={userId}&routineId={routineId}- List exercisesPOST /api/exercises?userId={userId}- Create exercisePATCH /api/exercises/{exerciseId}?userId={userId}- Update exerciseDELETE /api/exercises/{exerciseId}?userId={userId}- Delete exercise
{
id?: string;
userId: string;
date: string; // YYYY-MM-DD
name: string;
order: number;
}{
id?: string;
routineId: string;
userId: string;
name: string;
repetitions: number;
weight: number;
sets: number;
setsCompleted: number;
time: string; // mm:ss
distance: number; // miles
order: number;
}Deploy to Azure Functions:
- Create Azure Function App (Node.js 18, Windows/Linux)
- Create Azure Storage Account
- Configure application settings:
AZURE_STORAGE_CONNECTION_STRINGAPI_SHARED_KEY
- Deploy:
func azure functionapp publish <function-app-name>Azure Table Storage schema:
routines table
- PartitionKey: userId
- RowKey: routineId (auto-generated)
- Fields: date, name, order
exercises table
- PartitionKey: userId
- RowKey: exerciseId (auto-generated)
- Fields: routineId, name, repetitions, weight, sets, setsCompleted, time, distance, order