Add sitemap and robots.txt, update home page stats to static values, and fix prayer language detection

- Create sitemap.xml with internationalized routes and proper SEO attributes
- Create robots.txt with appropriate crawling rules for public/private content
- Update home page stats to show static values (1,416 Bible versions, 17M+ verses)
- Remove live stats API calls to eliminate loading delays
- Add /api/stats endpoint for potential future use
- Fix Romanian prayers incorrectly tagged as English in database
- Add missing AZURE_OPENAI_DEPLOYMENT to .env.example
- Update translation keys for Bible versions stat
- Add sample English prayer requests to populate prayer wall

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-25 06:41:02 +00:00
parent 14c4ec2edc
commit 3ae9733805
8 changed files with 356 additions and 13 deletions

View File

@@ -6,7 +6,9 @@ const createPrayerSchema = z.object({
title: z.string().min(1).max(200),
description: z.string().min(1).max(1000),
category: z.enum(['personal', 'family', 'health', 'work', 'ministry', 'world']),
isAnonymous: z.boolean().optional().default(false)
isAnonymous: z.boolean().optional().default(false),
isPublic: z.boolean().optional().default(false),
language: z.string().min(2).max(5).optional()
})
export async function GET(request: Request) {
@@ -14,7 +16,35 @@ export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
const category = searchParams.get('category')
const limit = parseInt(searchParams.get('limit') || '20')
const userId = searchParams.get('userId')
const visibility = (searchParams.get('visibility') || 'public').toLowerCase()
const languagesParam = searchParams.getAll('languages')
const languages = languagesParam
.flatMap(value =>
value
.split(',')
.map(part => part.trim().toLowerCase())
.filter(Boolean)
)
.filter((value, index, self) => self.indexOf(value) === index)
const authHeader = request.headers.get('authorization')
let sessionUserId: string | null = null
if (authHeader && authHeader.startsWith('Bearer ')) {
const token = authHeader.slice(7)
const session = await prisma.session.findUnique({
where: { token },
select: {
userId: true,
expiresAt: true
}
})
if (session && session.expiresAt > new Date()) {
sessionUserId = session.userId
}
}
// Build the where clause
const where: any = {
@@ -25,6 +55,30 @@ export async function GET(request: Request) {
where.category = category
}
if (visibility === 'private') {
if (!sessionUserId) {
return NextResponse.json(
{
success: false,
error: 'Authentication required to view private prayers',
prayers: []
},
{ status: 401 }
)
}
where.userId = sessionUserId
where.isPublic = false
} else {
where.isPublic = true
if (languages.length > 0) {
where.language = {
in: languages
}
}
}
// Fetch prayers from database with user prayer status
const prayers = await prisma.prayerRequest.findMany({
where,
@@ -38,9 +92,9 @@ export async function GET(request: Request) {
name: true
}
},
userPrayers: userId ? {
userPrayers: sessionUserId ? {
where: {
userId: userId
userId: sessionUserId
}
} : false
}
@@ -55,7 +109,10 @@ export async function GET(request: Request) {
author: prayer.isAnonymous ? 'Anonim' : prayer.author,
timestamp: prayer.createdAt,
prayerCount: prayer.prayerCount,
isPrayedFor: userId && prayer.userPrayers ? prayer.userPrayers.length > 0 : false
isPrayedFor: sessionUserId && prayer.userPrayers ? prayer.userPrayers.length > 0 : false,
isPublic: prayer.isPublic,
language: prayer.language,
isOwner: sessionUserId ? prayer.userId === sessionUserId : false
}))
return NextResponse.json({
@@ -100,6 +157,26 @@ export async function POST(request: Request) {
}
}
if (!userId && !validatedData.isAnonymous) {
return NextResponse.json(
{
success: false,
error: 'Authentication required'
},
{ status: 401 }
)
}
if (!validatedData.isPublic && !userId) {
return NextResponse.json(
{
success: false,
error: 'Authentication required for private prayers'
},
{ status: 401 }
)
}
// Create new prayer in database
const newPrayer = await prisma.prayerRequest.create({
data: {
@@ -108,6 +185,8 @@ export async function POST(request: Request) {
category: validatedData.category,
author: validatedData.isAnonymous ? 'Anonim' : userName,
isAnonymous: validatedData.isAnonymous,
isPublic: validatedData.isPublic ?? false,
language: validatedData.language?.toLowerCase() || 'en',
userId: validatedData.isAnonymous ? null : userId,
prayerCount: 0,
isActive: true
@@ -124,7 +203,10 @@ export async function POST(request: Request) {
author: newPrayer.author,
timestamp: newPrayer.createdAt,
prayerCount: newPrayer.prayerCount,
isPrayedFor: false
isPrayedFor: false,
isPublic: newPrayer.isPublic,
language: newPrayer.language,
isOwner: !!userId && newPrayer.userId === userId
},
message: 'Prayer request submitted successfully'
}, { status: 201 })

39
app/api/stats/route.ts Normal file
View File

@@ -0,0 +1,39 @@
import { NextResponse } from 'next/server';
import { prisma } from '@/lib/db';
export const runtime = 'nodejs';
export async function GET() {
try {
// Get bible statistics
const [
totalBibleVersions,
totalVerses,
totalBooks
] = await Promise.all([
// Count total Bible versions
prisma.bibleVersion.count(),
// Count total verses across all versions
prisma.bibleVerse.count(),
// Count unique books (66 biblical books)
prisma.bibleBook.groupBy({
by: ['bookKey'],
}).then(result => result.length)
]);
return NextResponse.json({
bibleVersions: totalBibleVersions,
verses: totalVerses,
books: totalBooks
});
} catch (error) {
console.error('Stats API error:', error);
return NextResponse.json(
{ error: 'Failed to fetch statistics' },
{ status: 500 }
);
}
}