mirror of
https://github.com/documenso/documenso.git
synced 2026-07-10 13:06:00 +10:00
7e2cbe46c0
### Summary - Add Cache-Control headers to all route responses (1h s-maxage, 2h stale-while-revalidate) - Append current month to chart data so graphs stay up-to-date (cumulative carries forward, else zero) - Remove `.limit(12)` from growth queries for full history - Pass isCumulative flag through addZeroMonth - Deduplicate TransformedData type, remove transformRepoStats
29 lines
711 B
TypeScript
29 lines
711 B
TypeScript
import cors from '@/lib/cors';
|
|
import { transformData } from '@/lib/transform-data';
|
|
|
|
export async function GET(request: Request) {
|
|
const res = await fetch('https://stargrazer-live.onrender.com/api/stats');
|
|
const data = await res.json();
|
|
const transformedData = transformData({ data, metric: 'openIssues' });
|
|
|
|
return cors(
|
|
request,
|
|
new Response(JSON.stringify(transformedData), {
|
|
status: 200,
|
|
headers: {
|
|
'content-type': 'application/json',
|
|
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=7200',
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function OPTIONS(request: Request) {
|
|
return cors(
|
|
request,
|
|
new Response(null, {
|
|
status: 204,
|
|
}),
|
|
);
|
|
}
|