-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetAuditLogs.js
More file actions
40 lines (35 loc) · 1009 Bytes
/
Copy pathgetAuditLogs.js
File metadata and controls
40 lines (35 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const {
fetchAllAuditLogs,
fetchAuditLogsByElectionId,
} = require('../../database/queries/security/fetchAuditLogs');
// Fetch all audit logs
const getAllAuditLogs = async (req, res) => {
try {
const auditLogs = await fetchAllAuditLogs();
res.status(200).json({ auditLogs });
} catch (error) {
res.status(500).json({
error: 'Failed to fetch audit logs',
details: error.message,
});
}
};
const getAuditLogsByElectionId = async (req, res) => {
const { electionId } = req.params;
try {
const auditLogs = await fetchAuditLogsByElectionId(electionId);
if (!auditLogs || auditLogs.length === 0) {
return res.status(404).json({ message: 'No audit logs found for the given election ID' });
}
res.status(200).json({ auditLogs });
} catch (error) {
res.status(500).json({
error: 'Failed to fetch audit logs by election ID',
details: error.message,
});
}
};
module.exports = {
getAllAuditLogs,
getAuditLogsByElectionId,
};