feat: implement user authentication and login modal, refactor backend
This commit is contained in:
22
web/backend/routes/logs.js
Normal file
22
web/backend/routes/logs.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import express from 'express';
|
||||
import { basicAuthMiddleware } from '../middlewares/auth.js';
|
||||
import { getLogPath, readLogs } from '../utils/fileUtils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Obtener logs (últimas líneas o nuevas líneas desde un número de línea)
|
||||
router.get('/', basicAuthMiddleware, (req, res) => {
|
||||
try {
|
||||
const logPath = getLogPath();
|
||||
const sinceLine = parseInt(req.query.since) || 0;
|
||||
const limit = parseInt(req.query.limit) || 500;
|
||||
|
||||
const result = readLogs(logPath, { sinceLine, limit });
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user