Enhance application structure: Add runtime configuration for environment variables, integrate new dependencies for Cloudinary and UI components, and refactor member management features including improved forms and member dashboard. Update styles and layout for better user experience.
This commit is contained in:
parent
6e7e27ac4e
commit
e4a0a9ab0f
61 changed files with 7902 additions and 950 deletions
47
server/api/admin/events/[id].get.js
Normal file
47
server/api/admin/events/[id].get.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import Event from '../../../models/event.js'
|
||||
import { connectDB } from '../../../utils/mongoose.js'
|
||||
import jwt from 'jsonwebtoken'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
// TODO: Temporarily disabled auth for testing - enable when authentication is set up
|
||||
// const token = getCookie(event, 'auth-token') || getHeader(event, 'authorization')?.replace('Bearer ', '')
|
||||
|
||||
// if (!token) {
|
||||
// throw createError({
|
||||
// statusCode: 401,
|
||||
// statusMessage: 'Authentication required'
|
||||
// })
|
||||
// }
|
||||
|
||||
// const config = useRuntimeConfig()
|
||||
// const decoded = jwt.verify(token, config.jwtSecret)
|
||||
|
||||
const eventId = getRouterParam(event, 'id')
|
||||
console.log('🔍 API: Get event by ID called')
|
||||
console.log('🔍 API: Event ID param:', eventId)
|
||||
|
||||
await connectDB()
|
||||
|
||||
const eventData = await Event.findById(eventId)
|
||||
console.log('🔍 API: Event data found:', eventData ? 'YES' : 'NO')
|
||||
console.log('🔍 API: Event data preview:', eventData ? { id: eventData._id, title: eventData.title } : null)
|
||||
|
||||
if (!eventData) {
|
||||
console.log('❌ API: Event not found in database')
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: 'Event not found'
|
||||
})
|
||||
}
|
||||
|
||||
console.log('✅ API: Returning event data')
|
||||
return { data: eventData }
|
||||
} catch (error) {
|
||||
console.error('❌ API: Error fetching event:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: error.message || 'Failed to fetch event'
|
||||
})
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue