Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

refactor: remove em dashes from all backend source files

valzor0771c87136dd
diff --git a/backend/lib/db.js b/backend/lib/db.js
index 60faacc..8216af0 100644
--- a/backend/lib/db.js
+++ b/backend/lib/db.js
@@ -1,7 +1,7 @@
-// All functions accept `supabase` as first argument so they work both in
+// All functions accept `supabase` as first argument so they work both in
// request handlers (where supabase comes from context) and in cron handlers
// (where supabase is created from env). userId=null means service-level
-// (no user filter) — used by the scheduler and token refresh cron.
+// (no user filter) - used by the scheduler and token refresh cron.
// ── Accounts ──────────────────────────────────────────────────────────────────
@@ -51,7 +51,7 @@ export async function deleteAccount(supabase, id, userId = null) {
}
// ── Settings (API Keys) ───────────────────────────────────────────────────────
-// Table: settings (user_id uuid, key text, value jsonb) — PK is (user_id, key)
+// Table: settings (user_id uuid, key text, value jsonb) - PK is (user_id, key)
const DEFAULT_KEYS = {};
diff --git a/backend/lib/supabase.js b/backend/lib/supabase.js
index c60fa67..dc0545e 100644
--- a/backend/lib/supabase.js
+++ b/backend/lib/supabase.js
@@ -1,11 +1,11 @@
-import { createClient } from '@supabase/supabase-js';
+import { createClient } from '@supabase/supabase-js';
-// Returns a service-role client that bypasses RLS — used for all DB operations.
+// Returns a service-role client that bypasses RLS - used for all DB operations.
export function getSupabase(env) {
return createClient(env.SUPABASE_URL, env.SUPABASE_SERVICE_KEY, { auth: { persistSession: false } });
}
-// Returns an anon client — used only to verify user JWTs in auth middleware.
+// Returns an anon client - used only to verify user JWTs in auth middleware.
export function getSupabaseAuth(env) {
return createClient(env.SUPABASE_URL, env.SUPABASE_ANON_KEY, { auth: { persistSession: false } });
}
diff --git a/backend/server.js b/backend/server.js
index 97c34c7..2f0160b 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -1,4 +1,4 @@
-import { Hono } from 'hono';
+import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { getSupabase } from './lib/supabase.js';
import { getRedis } from './lib/redis.js';
@@ -19,7 +19,7 @@ const app = new Hono();
app.use('*', cors());
// Attach Supabase and Redis clients to context for every request.
-// Both are stateless HTTP clients — safe to create per-request in Workers.
+// Both are stateless HTTP clients - safe to create per-request in Workers.
app.use('*', async (c, next) => {
c.set('supabase', getSupabase(c.env));
c.set('redis', getRedis(c.env));
@@ -30,7 +30,7 @@ app.use('*', async (c, next) => {
app.get('/api/health', (c) => c.json({ status: 'ok', timestamp: new Date().toISOString() }));
-// Instagram OAuth callback — public because it's a browser redirect (no JWT available).
+// Instagram OAuth callback - public because it's a browser redirect (no JWT available).
// The userId is recovered from the Redis state token instead.
app.get('/api/auth/instagram/callback', callbackHandler);
@@ -45,7 +45,7 @@ api.route('/', analyticsRouter);
api.route('/', publishingRouter);
api.route('/', scheduledPostsRouter);
-// Instagram OAuth URL generator — protected (needs userId to create state token)
+// Instagram OAuth URL generator - protected (needs userId to create state token)
api.get('/auth/instagram/url', urlHandler);
app.route('/api', api);
@@ -56,7 +56,7 @@ export default {
// Handles all HTTP requests
fetch: app.fetch,
- // Cron trigger handler — runs on the schedule defined in wrangler.toml:
+ // Cron trigger handler - runs on the schedule defined in wrangler.toml:
// "*/15 * * * *" → publish due scheduled posts
// "0 0 * * *" → refresh expiring Instagram tokens
async scheduled(event, env, ctx) {
diff --git a/backend/services/instagram.js b/backend/services/instagram.js
index 617c55e..447af3a 100644
--- a/backend/services/instagram.js
+++ b/backend/services/instagram.js
@@ -1,4 +1,4 @@
-// fetch is a global in Cloudflare Workers — no import needed.
+// fetch is a global in Cloudflare Workers - no import needed.
import { getAccounts, updateAccount } from '../lib/db.js';
const IG_GRAPH_URL = 'https://graph.instagram.com';
@@ -44,7 +44,7 @@ export async function exchangeForLongLivedToken(shortToken, appSecret) {
client_secret: appSecret,
access_token: shortToken,
});
- if (!data.access_token) throw new Error('Failed to exchange token — check Instagram App Secret');
+ if (!data.access_token) throw new Error('Failed to exchange token - check Instagram App Secret');
return {
accessToken: data.access_token,
tokenType: data.token_type || 'bearer',
@@ -83,7 +83,7 @@ export async function autoRefreshInstagramTokens(supabase) {
const refreshed = await refreshLongLivedToken(account.accessToken);
const tokenExpiresAt = new Date(Date.now() + (refreshed.expiresIn || 5184000) * 1000).toISOString();
await updateAccount(supabase, account.id, { accessToken: refreshed.accessToken, tokenExpiresAt });
- console.log(`Token refreshed for @${account.username} — expires ${tokenExpiresAt}`);
+ console.log(`Token refreshed for @${account.username} - expires ${tokenExpiresAt}`);
} catch (err) {
console.error(`Failed to refresh token for @${account.username}: ${err.message}`);
}
diff --git a/backend/services/youtube.js b/backend/services/youtube.js
index 54040b1..1c827d5 100644
--- a/backend/services/youtube.js
+++ b/backend/services/youtube.js
@@ -1,4 +1,4 @@
-// fetch is a global in Cloudflare Workers — no import needed.
+// fetch is a global in Cloudflare Workers - no import needed.
async function ytFetch(endpoint, params, apiKey) {
const url = new URL(`https://www.googleapis.com/youtube/v3/${endpoint}`);