Update app/server.js
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const express = require('express');
|
||||
const { Pool } = require('pg');
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
const pool = new Pool({
|
||||
user: 'your_user',
|
||||
host: 'localhost',
|
||||
database: 'backup_dashboard',
|
||||
password: 'your_password',
|
||||
port: 5432,
|
||||
});
|
||||
|
||||
app.get('/api/backups', async (req, res) => {
|
||||
try {
|
||||
const result = await pool.query(`
|
||||
SELECT
|
||||
company_name,
|
||||
backup_product,
|
||||
job_name,
|
||||
last_backup_time,
|
||||
status,
|
||||
error_details,
|
||||
next_backup_time
|
||||
FROM backup_jobs
|
||||
ORDER BY company_name, backup_product;
|
||||
`);
|
||||
res.json(result.rows);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).send('Server error');
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Backend running on http://localhost:${port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user