Initial commit: Digital Home dashboard

This commit is contained in:
Cosmo
2026-04-15 20:31:28 +00:00
commit c5c4603903
33 changed files with 1384 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
export const dynamic = "force-dynamic";
import { NextResponse } from "next/server";
const PULSE_API = "https://api.digital-home.site";
const REFRESH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE4MDIwMjY5NDgsImlhdCI6MTc3MDQ5MDk0OCwidHlwZSI6InJlZnJlc2giLCJ1c2VyX2lkIjoxfQ.zPJJB7o9vtnfIBFl7rNygEEXd9h-5YZeAxRIvWcRlXY";
async function getAccessToken(): Promise<string> {
const res = await fetch(`${PULSE_API}/auth/refresh`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ refresh_token: REFRESH_TOKEN }),
});
if (!res.ok) throw new Error("Failed to refresh token");
const data = await res.json();
return data.access_token;
}
export async function GET() {
try {
const token = await getAccessToken();
const res = await fetch(`${PULSE_API}/tasks?due_today=true`, {
headers: { Authorization: `Bearer ${token}` },
next: { revalidate: 60 },
});
if (!res.ok) {
return NextResponse.json({ tasks: [] });
}
const data = await res.json();
return NextResponse.json(data);
} catch (e) {
return NextResponse.json({ tasks: [] });
}
}