Files
Compass/app/api/interests/route.ts
MartinBraquet 7205245d29 Add core values
2025-08-02 19:22:03 +02:00

61 lines
1.3 KiB
TypeScript

import { prisma } from "@/lib/server/prisma";
import { NextResponse } from "next/server";
export async function GET() {
try {
// Get all interests from the database
const cacheStrategy = { swr: 60, ttl: 60, tags: ["interests"] };
const interests = await prisma.interest.findMany({
select: {
id: true,
name: true,
},
orderBy: {
name: 'asc'
},
cacheStrategy: cacheStrategy,
});
const coreValues = await prisma.value.findMany({
select: {
id: true,
name: true,
},
orderBy: {
name: 'asc'
},
cacheStrategy: cacheStrategy,
});
const causeAreas = await prisma.causeArea.findMany({
select: {
id: true,
name: true,
},
orderBy: {
name: 'asc'
},
cacheStrategy: cacheStrategy,
});
const connections = await prisma.connection.findMany({
select: {
id: true,
name: true,
},
orderBy: {
name: 'asc'
},
cacheStrategy: cacheStrategy,
});
return NextResponse.json({ interests, coreValues, causeAreas, connections });
} catch (error) {
console.error('Error fetching interests:', error);
return NextResponse.json(
{ error: "Failed to fetch interests" },
{ status: 500 }
);
}
}