26 lines
686 B
TypeScript
26 lines
686 B
TypeScript
import { getActiveBlocklistCount } from "../../db/domains";
|
||
|
||
const FALLBACK_TOTAL = 208704;
|
||
|
||
/** GET /api/community/domain-stats – öffentlich, kein Auth */
|
||
export default defineEventHandler(async () => {
|
||
const db = usePrisma();
|
||
|
||
const [rawTotal, monthlyAdded] = await Promise.all([
|
||
getActiveBlocklistCount(),
|
||
(async () => {
|
||
const startOfMonth = new Date();
|
||
startOfMonth.setDate(1);
|
||
startOfMonth.setHours(0, 0, 0, 0);
|
||
return db.domainSubmission.count({
|
||
where: { status: "approved", reviewedAt: { gte: startOfMonth } },
|
||
});
|
||
})(),
|
||
]);
|
||
|
||
return {
|
||
total: rawTotal > 1000 ? rawTotal : FALLBACK_TOTAL,
|
||
monthlyAdded,
|
||
};
|
||
});
|