Files
formbricks/apps/web/app/api/cron/ping/route.ts
T
Dhruwang Jariwala ab80bc1bf2 feat: language switch (#2692)
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
2024-06-12 14:10:22 +00:00

31 lines
841 B
TypeScript

import { responses } from "@/app/lib/api/response";
import packageJson from "@/package.json";
import { headers } from "next/headers";
import { prisma } from "@formbricks/database";
import { CRON_SECRET } from "@formbricks/lib/constants";
import { captureTelemetry } from "@formbricks/lib/telemetry";
export const POST = async () => {
const headersList = headers();
const apiKey = headersList.get("x-api-key");
if (!apiKey || apiKey !== CRON_SECRET) {
return responses.notAuthenticatedResponse();
}
const [surveyCount, responseCount, userCount] = await Promise.all([
prisma.survey.count(),
prisma.response.count(),
prisma.user.count(),
]);
captureTelemetry("ping", {
version: packageJson.version,
surveyCount,
responseCount,
userCount,
});
return responses.successResponse({}, true);
};