Update various configuration files, components, and assets; enhance notification system and API endpoints; improve documentation and styles across the application.
This commit is contained in:
44
server/api/notifications/logs/[id].get.js
Normal file
44
server/api/notifications/logs/[id].get.js
Normal file
@@ -0,0 +1,44 @@
|
||||
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 }
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user