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: keys route now returns server env var status instead of per-user DB settings

valzord8d6596938a4
diff --git a/backend/routes/keys.js b/backend/routes/keys.js
index d2a1b5c..92138fc 100644
--- a/backend/routes/keys.js
+++ b/backend/routes/keys.js
@@ -1,54 +1,15 @@
-const router = require('express').Router();
-const { readJSON, writeJSON, API_KEYS_FILE } = require('../utils/dataHelpers');
+import { Hono } from 'hono';
-router.get('/', async (req, res) => {
- const keys = await readJSON(API_KEYS_FILE);
- res.json({
- youtube: keys?.youtube || '',
- configured: !!keys?.youtube,
- instagram: {
- appId: keys?.instagram?.appId || '',
- appSecret: keys?.instagram?.appSecret || '',
- configured: !!(keys?.instagram?.appId && keys?.instagram?.appSecret),
- },
- cloudinary: {
- cloudName: keys?.cloudinary?.cloudName || '',
- uploadPreset: keys?.cloudinary?.uploadPreset || '',
- configured: !!(keys?.cloudinary?.cloudName && keys?.cloudinary?.uploadPreset),
- },
- github: {
- token: keys?.github?.token || '',
- repo: keys?.github?.repo || '',
- branch: keys?.github?.branch || 'main',
- configured: !!(keys?.github?.token && keys?.github?.repo),
- },
- });
-});
-
-router.post('/', async (req, res) => {
- const { youtube, instagram, cloudinary, github } = req.body;
- const keys = await readJSON(API_KEYS_FILE) || {};
+const app = new Hono();
- if (youtube !== undefined) keys.youtube = youtube;
- if (instagram !== undefined) {
- if (!keys.instagram) keys.instagram = {};
- if (instagram.appId !== undefined) keys.instagram.appId = instagram.appId;
- if (instagram.appSecret !== undefined) keys.instagram.appSecret = instagram.appSecret;
- }
- if (cloudinary !== undefined) {
- if (!keys.cloudinary) keys.cloudinary = {};
- if (cloudinary.cloudName !== undefined) keys.cloudinary.cloudName = cloudinary.cloudName;
- if (cloudinary.uploadPreset !== undefined) keys.cloudinary.uploadPreset = cloudinary.uploadPreset;
- }
- if (github !== undefined) {
- if (!keys.github) keys.github = { branch: 'main' };
- if (github.token !== undefined) keys.github.token = github.token;
- if (github.repo !== undefined) keys.github.repo = github.repo;
- if (github.branch !== undefined) keys.github.branch = github.branch || 'main';
- }
-
- const ok = await writeJSON(API_KEYS_FILE, keys);
- res.json({ success: ok, message: ok ? 'API keys saved' : 'Failed to save' });
+// All API keys (YouTube, Instagram, Cloudinary) are server env vars.
+// This route returns a status object so the frontend can confirm the backend is reachable.
+app.get('/keys', (c) => {
+ return c.json({
+ youtube: { configured: !!c.env.YOUTUBE_API_KEY },
+ instagram: { configured: !!(c.env.INSTAGRAM_APP_ID && c.env.INSTAGRAM_APP_SECRET) },
+ cloudinary: { configured: !!(c.env.CLOUDINARY_CLOUD_NAME && c.env.CLOUDINARY_UPLOAD_PRESET) },
+ });
});
-module.exports = router;
+export default app;