Spaces:
Sleeping
Sleeping
Nathan commited on
Commit ·
0acfe9d
1
Parent(s): b4b999b
Debug: Added Database Link Tester to dashboard
Browse filesFiles changed (2)
- dashboard/index.html+23
- server.js+20-1
255 unmodified lines256257258259260261392 unmodified lines654655656657658659255 unmodified lines</div></div><div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--glass-border); display: flex; justify-content: space-between;"><span style="font-size: 0.8rem; color: var(--text-dim);">System Health:</span><span style="color: var(--success); font-size: 0.8rem; font-weight: 800; display: flex; align-items: center; gap: 5px;">392 unmodified lines}}checkAuth();lucide.createIcons();255 unmodified lines256257258259260261262263264265266392 unmodified lines659660661662663664665666667668669670671672673674675676677678679680681682255 unmodified lines</div></div><div style="margin-top: 15px; display: flex; gap: 10px;"><button class="btn-primary" onclick="testDatabaseLink()" style="background: rgba(99, 102, 241, 0.1); font-size: 0.7rem; padding: 5px 12px; border: 1px dashed var(--accent);">🔧 Test Database Link</button><button class="btn-primary" onclick="updateLogs()" style="background: rgba(16, 185, 129, 0.1); font-size: 0.7rem; padding: 5px 12px; border: 1px dashed var(--success);">🔄 Force Sync Logs</button></div><div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--glass-border); display: flex; justify-content: space-between;"><span style="font-size: 0.8rem; color: var(--text-dim);">System Health:</span><span style="color: var(--success); font-size: 0.8rem; font-weight: 800; display: flex; align-items: center; gap: 5px;">392 unmodified lines}}async function testDatabaseLink() {try {const res = await fetch('/api/test-db', {method: 'POST',headers: { 'Authorization': `Bearer ${authToken}` }});if (res.ok) {alert("✅ Test signal sent! Refreshing logs...");updateLogs();} else {const d = await res.json();alert("❌ Database Error: " + (d.error || "Unknown error"));}} catch (e) {alert("❌ Connection failed.");}}checkAuth();lucide.createIcons();
153 unmodified lines154155156157158159484 unmodified lines644645646647648649650651652653654655153 unmodified lines}});app.get('/api/auth/me', authenticateToken, async (req, res) => {try {let { data: user } = await db.from('users').select('email, role, plan, plan_expires_at').eq('id', req.userId).single();484 unmodified lines});app.get('/api/logs', authenticateToken, async (req, res) => {const { data: logs } = await db.from('activity').select('created_at, message, type, metadata').eq('user_id', req.userId).order('created_at', { ascending: false }).limit(20);res.json((logs || []).map(l => ({time: l.created_at,msg: l.message,153 unmodified lines154155156157158159160161162163164165166167168169170171172173484 unmodified lines658659660661662663664665666667668669670671672673674153 unmodified lines}});app.post('/api/test-db', authenticateToken, async (req, res) => {try {const { error } = await db.from('activity').insert([{user_id: req.userId,type: 'LOG',message: '🧪 Database Connection Test Successful!'}]);if (error) throw error;res.json({ success: true });} catch (e) {res.status(500).json({ error: e.message });}});app.get('/api/auth/me', authenticateToken, async (req, res) => {try {let { data: user } = await db.from('users').select('email, role, plan, plan_expires_at').eq('id', req.userId).single();484 unmodified lines});app.get('/api/logs', authenticateToken, async (req, res) => {const { data: logs, error } = await db.from('activity').select('created_at, message, type, metadata').eq('user_id', req.userId).order('created_at', { ascending: false }).limit(20);if (error) {console.error("🔥 [API/Logs] DB Error:", error.message);return res.status(500).json({ error: error.message });}res.json((logs || []).map(l => ({time: l.created_at,msg: l.message,
dashboard/index.html+23
server.js+20-1