@lifeaitools/clauth 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/serve.js +20 -28
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -1282,39 +1282,31 @@ function createServer(initPassword, whitelist, port, tunnelHostname = null) {
|
|
|
1282
1282
|
// ── Build status (populated via Supabase Realtime) ─────────
|
|
1283
1283
|
let buildStatus = { active: false, status: "idle", apps: [], updated_at: null };
|
|
1284
1284
|
|
|
1285
|
-
|
|
1285
|
+
// Poll Supabase REST API for build status (no extra deps needed)
|
|
1286
|
+
async function fetchBuildStatus() {
|
|
1286
1287
|
try {
|
|
1287
1288
|
const sbUrl = (api.getBaseUrl() || "").replace("/functions/v1/auth-vault", "");
|
|
1288
1289
|
const sbKey = api.getAnonKey();
|
|
1289
1290
|
if (!sbUrl || !sbKey) return;
|
|
1290
1291
|
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
.
|
|
1301
|
-
(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
.subscribe();
|
|
1310
|
-
|
|
1311
|
-
const logMsg = `[${new Date().toISOString()}] Build status: Realtime subscription active\n`;
|
|
1312
|
-
try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
|
|
1313
|
-
} catch (err) {
|
|
1314
|
-
const logMsg = `[${new Date().toISOString()}] Build status subscription failed: ${err.message}\n`;
|
|
1315
|
-
try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
|
|
1316
|
-
}
|
|
1317
|
-
})();
|
|
1292
|
+
const r = await fetch(
|
|
1293
|
+
`${sbUrl}/rest/v1/prt_storage?key=eq.build_status&select=value`,
|
|
1294
|
+
{ headers: { apikey: sbKey, Authorization: `Bearer ${sbKey}` }, signal: AbortSignal.timeout(5000) }
|
|
1295
|
+
);
|
|
1296
|
+
if (!r.ok) return;
|
|
1297
|
+
const rows = await r.json();
|
|
1298
|
+
if (rows.length > 0 && rows[0].value) {
|
|
1299
|
+
const prev = buildStatus.status;
|
|
1300
|
+
buildStatus = typeof rows[0].value === "string" ? JSON.parse(rows[0].value) : rows[0].value;
|
|
1301
|
+
if (buildStatus.status !== prev) {
|
|
1302
|
+
const logMsg = `[${new Date().toISOString()}] Build status: ${buildStatus.status} (${buildStatus.commit?.slice(0,8) || "?"})\n`;
|
|
1303
|
+
try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
} catch {}
|
|
1307
|
+
}
|
|
1308
|
+
fetchBuildStatus();
|
|
1309
|
+
setInterval(fetchBuildStatus, 15000);
|
|
1318
1310
|
|
|
1319
1311
|
const server = http.createServer(async (req, res) => {
|
|
1320
1312
|
const remote = req.socket.remoteAddress;
|