Checkpoint before follow-up message
Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { projectService } from '@/lib/prisma';
|
||||
import { prisma, projectService } from '@/lib/prisma';
|
||||
import { requireSessionAuth } from '@/lib/auth';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
@@ -9,16 +9,39 @@ export async function GET(request: NextRequest) {
|
||||
const authError = requireSessionAuth(request);
|
||||
if (authError) return authError;
|
||||
|
||||
// Get all projects with full data
|
||||
const projectsResult = await projectService.getAllProjects();
|
||||
// Projects (with translations)
|
||||
const projectsResult = await projectService.getAllProjects({ limit: 10000 });
|
||||
const projects = projectsResult.projects || projectsResult;
|
||||
const projectIds = projects.map((p: { id: number }) => p.id);
|
||||
|
||||
const projectTranslations = await prisma.projectTranslation.findMany({
|
||||
where: { projectId: { in: projectIds } },
|
||||
orderBy: [{ projectId: 'asc' }, { locale: 'asc' }],
|
||||
});
|
||||
|
||||
// CMS content pages (with translations)
|
||||
const contentPages = await prisma.contentPage.findMany({
|
||||
orderBy: { key: 'asc' },
|
||||
include: {
|
||||
translations: {
|
||||
orderBy: { locale: 'asc' },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const siteSettings = await prisma.siteSettings.findUnique({ where: { id: 1 } });
|
||||
|
||||
// Format for export
|
||||
const exportData = {
|
||||
version: '1.0',
|
||||
version: '2.0',
|
||||
exportDate: new Date().toISOString(),
|
||||
siteSettings,
|
||||
contentPages,
|
||||
projectTranslations,
|
||||
projects: projects.map(project => ({
|
||||
id: project.id,
|
||||
slug: (project as unknown as { slug?: string }).slug,
|
||||
defaultLocale: (project as unknown as { defaultLocale?: string }).defaultLocale,
|
||||
title: project.title,
|
||||
description: project.description,
|
||||
content: project.content,
|
||||
|
||||
Reference in New Issue
Block a user