Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
📅 Normalize GitHub repository format in sync functions
valzorbbaa8231ec5d
diff --git a/backend/nodemon.json b/backend/nodemon.jsonnew file mode 100644index 0000000..87b5a90--- /dev/null+++ b/backend/nodemon.json@@ -0,0 +1,10 @@+{+ "watch": [+ "server.js"+ ],+ "ignore": [+ "data/*",+ "*.json"+ ],+ "ext": "js"+}\ No newline at end of filediff --git a/backend/server.js b/backend/server.jsindex d2aea3b..72e77a8 100644--- a/backend/server.js+++ b/backend/server.js@@ -67,6 +67,9 @@ async function syncScheduledPostsToGitHub() {const gh = keys.github;if (!gh?.token || !gh?.repo) return; // Not configured+ // Normalize repo: accept full URL or owner/repo format+ const repo = gh.repo.replace(/^https?:\/\/github\.com\//, '').replace(/\.git$/, '').replace(/\/$/, '');+const posts = await readJSON(SCHEDULED_POSTS_FILE) || [];const content = Buffer.from(JSON.stringify(posts, null, 2)).toString('base64');const filePath = 'backend/data/scheduled_posts.json';@@ -75,7 +78,7 @@ async function syncScheduledPostsToGitHub() {// Get current file SHA (needed for updates)let sha;try {- const res = await fetch(`https://api.github.com/repos/${gh.repo}/contents/${filePath}?ref=${branch}`, {+ const res = await fetch(`https://api.github.com/repos/${repo}/contents/${filePath}?ref=${branch}`, {headers: { Authorization: `token ${gh.token}`, 'User-Agent': 'SocialMediaDashboard' }});if (res.ok) {@@ -88,7 +91,7 @@ async function syncScheduledPostsToGitHub() {const body = { message: '📅 Sync scheduled posts', content, branch };if (sha) body.sha = sha;- const res = await fetch(`https://api.github.com/repos/${gh.repo}/contents/${filePath}`, {+ const res = await fetch(`https://api.github.com/repos/${repo}/contents/${filePath}`, {method: 'PUT',headers: {Authorization: `token ${gh.token}`,@@ -115,10 +118,13 @@ async function pullScheduledPostsFromGitHub() {const gh = keys.github;if (!gh?.token || !gh?.repo) return;+ // Normalize repo: accept full URL or owner/repo format+ const repo = gh.repo.replace(/^https?:\/\/github\.com\//, '').replace(/\.git$/, '').replace(/\/$/, '');+const filePath = 'backend/data/scheduled_posts.json';const branch = gh.branch || 'main';- const res = await fetch(`https://api.github.com/repos/${gh.repo}/contents/${filePath}?ref=${branch}`, {+ const res = await fetch(`https://api.github.com/repos/${repo}/contents/${filePath}?ref=${branch}`, {headers: { Authorization: `token ${gh.token}`, 'User-Agent': 'SocialMediaDashboard' }});if (!res.ok) return;