Last Updated: 2025-12-24
Completed Phases:
Current Issue:
Enhancing iOS Share Sheet Backend with AI-powered daily summaries and PWA frontend.
Token: OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY
https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run
Email: jb@saluamigo.com
Name: John B.
Files Created:
backend/database/migrations_v2.ts - New tables for user settings and daily summariesbackend/database/queries_v2.ts - Date-range and summary query functionsFiles Modified:
shared/types.ts - Added UserSettings and DailySummary interfacesbackend/index.ts - Runs v2 migrations on startupDatabase Tables:
user_settings (userId, emailEnabled, smsEnabled, smsPhone, summaryTime, timezone, summaryTone, summaryLength, includeContentTypes, createdAt, updatedAt) daily_summaries (id, userId, summary, contentItemsCount, contentTypes, generatedAt, deliveredAt, createdAt)
Files Created:
backend/services/aiService.ts - AI summary generation with OpenRouter/Groq/Straicobackend/services/emailService.ts - Email delivery via Val Town std/emailbackend/services/smsService.ts - SMS delivery via Zapier webhooksFiles Modified:
backend/routes/content.ts - Added test endpoints for AI functionalitybackend/routes/auth.ts - Added test endpoints for authentication bypassEnvironment Variables (configured in Val Town):
AI_PROVIDER=openrouter
AI_API_KEY=sk-or-v1-...
AI_BASE_URL=https://openrouter.ai/api/v1
Test Endpoints Added:
POST /api/content/ai-summary-test - Generate summary from last 24h contentPOST /api/content/add-sample-data - Add 7 sample content itemsGET /api/content/ai-test - Test AI service configurationPOST /api/content/test-email - Send test emailPOST /api/auth/test-create-token - Create bearer token (bypasses auth)POST /api/auth/test-login - Test login (bypasses WebAuthn)GET /backend/test/createUser - Create user account (no WebAuthn)Testing Phase 2:
# Test page https://www.val.town/x/jaballadares/test-phase2 # Or manual testing: curl -X POST "https://jaballadares.../api/content/ai-summary-test" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY"
iOS Shortcuts "Get Contents of URL" action sends GET requests instead of POST to /api/content, despite being configured for POST method with headers and body.
# This curl command from iSH terminal works perfectly: curl -X POST \ "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY" \ -H "Content-Type: application/json" \ -d '{"type":"text","content":"Test from iSH","title":"iSH Test"}' # Returns: {"success":true,"id":"...","message":"Content saved successfully"}
https://jaballadares.../api/contentGET /api/content 401 Unauthorized with NO Authorization headerJust deployed to backend/routes/content.ts:
Log output format:
=== INCOMING REQUEST ===
Timestamp: ...
Method: GET or POST
URL: /api/content
Headers: {...}
Body: {...}
========================
=== BEARER TOKEN CHECK ===
Auth header: Bearer...
ā
Auth successful for user: jb@saluamigo.com
Investigate why iOS Shortcuts sends GET instead of POST:
cron/generateDailySummaries.cron.tsxcron/deliverSummaries.cron.tsxfrontend/components/Settings.tsx - User preferences for summariesfrontend/components/Summaries.tsx - View past summariesbackend/routes/settings.ts - Settings API endpointsbackend/routes/summaries.ts - Summaries API endpointsFile: backend/routes/content.ts
Added comprehensive logging middleware:
// Logs ALL requests to /api/content
content.use("/*", async (c, next) => {
console.log("=== INCOMING REQUEST ===");
console.log("Timestamp:", new Date().toISOString());
console.log("Method:", c.req.method);
console.log("URL:", c.req.url);
console.log("Path:", c.req.path);
console.log("Headers:", Object.fromEntries(c.req.header()));
console.log("Body:", body || "(empty)");
await next();
});
// Enhanced bearer token logging
async function requireBearerToken(c: any, next: any) {
console.log("=== BEARER TOKEN CHECK ===");
console.log("Auth header:", authHeader ? authHeader.substring(0, 20) + "..." : "(none)");
// ... detailed logging through auth flow
}
File: frontend/components/Setup.tsx
Fixed misleading UI that claimed downloadable iOS shortcut existed:
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY" \ -H "Content-Type: application/json" \ -d '{"type":"text","content":"Test note","title":"Test"}'
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content/ai-summary-test" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY"
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content/add-sample-data" \ -H "Authorization: Bearer OmjRJn2c3JEm_1bUFwLwmX_DZtxWUsvBaVHZca18BUY"
curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/auth/test-create-token" \ -H "Content-Type: application/json" \ -d '{"email":"jb@saluamigo.com"}'
# Must be logged in via browser first curl -X POST "https://jaballadares--019b2ebadc2370e4a6e633077cdb8332.web.val.run/api/content/test-email" \ -H "Content-Type: application/json"
/api/auth/test-loginusers - User accountsweb_authn_credentials - Passkeys (not used currently)bearer_tokens - API access tokens for shortcutscontent_items - Captured content (text, images, URLs)user_settings - Summary preferences (email, SMS, tone, length, timezone)daily_summaries - Generated daily summariesHIGH PRIORITY: Resolve iOS Shortcuts GET vs POST issue
After iOS Shortcuts works:
Nice to have:
/backend in this repoWhy does iOS Shortcuts send GET instead of POST?
Why is Authorization header not being sent?
Workarounds to try:
Good luck with the debugging! The backend is solid - just need to figure out what iOS Shortcuts is doing differently than curl. š