feat: open page api (#1419)

This commit is contained in:
Ephraim Duncan
2024-12-10 10:19:05 +00:00
committed by GitHub
parent 34c0868d77
commit 9d02ab4a5e
32 changed files with 1026 additions and 40 deletions

View File

@ -0,0 +1,35 @@
import type { NextRequest } from 'next/server';
import cors from '@/lib/cors';
const paths = [
{ path: 'github', description: 'GitHub Data' },
{ path: 'community', description: 'Community Data' },
{ path: 'growth', description: 'Growth Data' },
];
export function GET(request: NextRequest) {
const url = request.nextUrl.toString();
const apis = paths.map(({ path, description }) => {
return { path: url + path, description };
});
return cors(
request,
new Response(JSON.stringify(apis), {
status: 200,
headers: {
'content-type': 'application/json',
},
}),
);
}
export function OPTIONS(request: Request) {
return cors(
request,
new Response(null, {
status: 204,
}),
);
}