44 lines
1010 B
JavaScript
44 lines
1010 B
JavaScript
import prisma from '~/server/utils/prisma'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
// Check authentication
|
|
const user = event.context.user;
|
|
if (!user || !user.userID) {
|
|
return {
|
|
statusCode: 401,
|
|
body: { success: false, message: 'Unauthorized' }
|
|
}
|
|
}
|
|
|
|
const id = event.context.params.id
|
|
if (!id) {
|
|
return {
|
|
statusCode: 400,
|
|
body: { success: false, message: 'Log ID is required' }
|
|
}
|
|
}
|
|
|
|
const log = await prisma.notification_logs.findUnique({
|
|
where: { id }
|
|
})
|
|
|
|
if (!log) {
|
|
return {
|
|
statusCode: 404,
|
|
body: { success: false, message: 'Log entry not found' }
|
|
}
|
|
}
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: { success: true, data: log }
|
|
}
|
|
} catch (error) {
|
|
console.error('Error fetching log entry:', error)
|
|
return {
|
|
statusCode: 500,
|
|
body: { success: false, message: 'Failed to fetch log entry', error: error.message }
|
|
}
|
|
}
|
|
})
|