23 lines
604 B
TypeScript
23 lines
604 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { gql, GraphQLClient } from 'graphql-request';
|
|
|
|
|
|
const GET_CONFIGS = gql`
|
|
query GetConfigs {
|
|
siteConfigs {
|
|
key
|
|
value
|
|
}
|
|
}
|
|
`
|
|
|
|
export async function GET(request: NextRequest) {
|
|
const client = new GraphQLClient(process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql');
|
|
try {
|
|
const data: any = await client.request(GET_CONFIGS);
|
|
return NextResponse.json(data.siteConfigs);
|
|
} catch (error) {
|
|
return NextResponse.json({ error: 'No site configs found' }, { status: 404 });
|
|
}
|
|
|
|
} |