Actually remove the conflicting [id].delete.ts file from git
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import { isAuthenticated } from '~/server/utils/auth'
|
||||
import { getDatabase } from '~/server/utils/database'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
// Check authentication
|
||||
if (!isAuthenticated(event)) {
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
message: 'Unauthorized'
|
||||
})
|
||||
}
|
||||
|
||||
const id = getRouterParam(event, 'id')
|
||||
|
||||
if (!id) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: 'Sermon ID is required'
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
const db = getDatabase()
|
||||
const result = db.prepare('DELETE FROM sermons WHERE id = ?').run(parseInt(id))
|
||||
|
||||
if (result.changes === 0) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
message: 'Sermon not found'
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'Sermon deleted successfully'
|
||||
}
|
||||
} catch (error: any) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: error.message || 'Failed to delete sermon'
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user