Features added: - Database schema for pages and media files with content types (Rich Text, HTML, Markdown) - Admin API routes for full page CRUD operations - Image upload functionality with file management - Rich text editor using TinyMCE with image insertion - Admin interface for creating/editing pages with SEO options - Dynamic navigation and footer integration - Public page display routes with proper SEO metadata - Support for featured images and content excerpts Admin features: - Create/edit/delete pages with rich content editor - Upload and manage images through media library - Configure pages to appear in navigation or footer - Set page status (Draft, Published, Archived) - SEO title and description management - Real-time preview of content changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { prisma } from '@/lib/db'
|
|
import { CacheManager } from '@/lib/cache'
|
|
|
|
export const runtime = 'nodejs'
|
|
|
|
export async function GET(request: Request) {
|
|
try {
|
|
const { searchParams } = new URL(request.url)
|
|
const bookId = searchParams.get('book') || ''
|
|
const chapterNum = parseInt(searchParams.get('chapter') || '1')
|
|
const versionId = searchParams.get('version') || ''
|
|
|
|
// Check cache first (include version in cache key)
|
|
const cacheKey = CacheManager.getChapterKey(bookId, chapterNum, versionId)
|
|
const cachedChapter = await CacheManager.get(cacheKey)
|
|
|
|
if (cachedChapter) {
|
|
return NextResponse.json({
|
|
chapter: JSON.parse(cachedChapter),
|
|
cached: true
|
|
})
|
|
}
|
|
|
|
// Get chapter with verses from database
|
|
const chapter = await prisma.bibleChapter.findFirst({
|
|
where: {
|
|
bookId,
|
|
chapterNum,
|
|
book: versionId ? { versionId } : undefined
|
|
},
|
|
include: {
|
|
verses: {
|
|
orderBy: {
|
|
verseNum: 'asc'
|
|
}
|
|
},
|
|
book: {
|
|
include: {
|
|
version: true
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
if (!chapter) {
|
|
return NextResponse.json({ error: 'Capitolul nu a fost găsit' }, { status: 404 })
|
|
}
|
|
|
|
const chapterData = {
|
|
id: chapter.id,
|
|
bookName: chapter.book.name,
|
|
chapterNum: chapter.chapterNum,
|
|
verses: chapter.verses
|
|
}
|
|
|
|
// Cache the result for 1 hour
|
|
await CacheManager.set(cacheKey, JSON.stringify(chapterData), 3600)
|
|
|
|
return NextResponse.json({
|
|
chapter: chapterData,
|
|
cached: false
|
|
})
|
|
} catch (error) {
|
|
console.error('Chapter fetch error:', error)
|
|
return NextResponse.json({ error: 'Eroare de server' }, { status: 500 })
|
|
}
|
|
}
|