1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-05 18:55:28 -04:00
Files
jarv.is/app/api/hits/route.ts
T
jake 5a1636baa3 refactor: migrate from Biome to oxlint/oxfmt, remove contact form
- Replace Biome with oxlint + oxfmt (OXC toolchain) for linting and formatting
- Add .oxlintrc.json and .oxfmtrc.json configuration files
- Update VS Code settings and devcontainer to use oxc-vscode extension
- Remove contact form, Resend email integration, and related server action/schema
- Remove unused UI components (accordion, alert, card, tabs, toggle, etc.)
2026-04-05 19:45:18 -04:00

31 lines
719 B
TypeScript

import { NextResponse } from "next/server";
import { getAllViewCounts } from "@/lib/server/views";
export const GET = async (): Promise<
NextResponse<{
total: {
hits: number;
};
pages: Array<{
slug: string;
hits: number;
}>;
}>
> => {
// note: while hits have been renamed to views in most places, this API shouldn't change due to it being snapshotted
const views = await getAllViewCounts();
const total = {
hits: Object.values(views).reduce((acc, curr) => acc + curr, 0),
};
const pages = Object.entries(views).map(([slug, count]) => ({
slug,
hits: count,
}));
pages.sort((a, b) => b.hits - a.hits);
return NextResponse.json({ total, pages });
};