debug: add database telemetry to portal finance endpoint
Build and Deploy (Gitea) / build-and-deploy (push) Has been cancelled
Details
Build and Deploy (Gitea) / build-and-deploy (push) Has been cancelled
Details
This commit is contained in:
parent
f2b8d59aa6
commit
438c175246
|
|
@ -0,0 +1,28 @@
|
|||
import fetch from 'node-fetch';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const loginRes = await fetch('https://aluno.microtecinformaticacurso.com.br/api/portal/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
enrollmentNumber: 'MAT-202600005',
|
||||
password: '068467'
|
||||
})
|
||||
});
|
||||
const loginData = await loginRes.json();
|
||||
console.log('Login Response:', loginData);
|
||||
|
||||
if (loginData.token) {
|
||||
const finRes = await fetch('https://aluno.microtecinformaticacurso.com.br/api/portal/financeiro', {
|
||||
headers: { Authorization: `Bearer ${loginData.token}` }
|
||||
});
|
||||
const finData = await finRes.json();
|
||||
console.log('Financeiro API Response:', JSON.stringify(finData, null, 2));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error during test:', err);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
|
|
@ -314,6 +314,7 @@ app.get('/api/portal/financeiro', authMiddleware, async (req, res) => {
|
|||
dbRows = rows || [];
|
||||
} catch (dbErr) {
|
||||
console.error('Financeiro: erro ao buscar do PostgreSQL -', dbErr.message);
|
||||
return res.status(500).json({ error: 'Erro no SQL: ' + dbErr.message, studentId: req.user.studentId });
|
||||
}
|
||||
|
||||
// 2. CONSTRUIR LISTA FINAL: Apenas registros do SQL (fonte única da verdade)
|
||||
|
|
@ -372,7 +373,11 @@ app.get('/api/portal/financeiro', authMiddleware, async (req, res) => {
|
|||
});
|
||||
}
|
||||
|
||||
res.json({ payments: finalPayments });
|
||||
res.json({
|
||||
payments: finalPayments,
|
||||
debugStudentId: req.user.studentId,
|
||||
dbRowsCount: dbRows.length
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Financeiro error:', err);
|
||||
res.status(500).json({ error: 'Erro interno' });
|
||||
|
|
|
|||
Loading…
Reference in New Issue