Display TpLink Tapo power usage values

This commit is contained in:
Jack Mechem 2026-05-21 16:08:53 -07:00
parent e6b5fed399
commit a0487c0b59
Signed by: jackmechem
SSH key fingerprint: SHA256:GjIjMAC33pzYOe+hWcX5uvgnPrVFAXSrquvt84AOJbU
5 changed files with 187 additions and 0 deletions

18
app/api/power/route.ts Normal file
View file

@ -0,0 +1,18 @@
import { NextRequest, NextResponse } from "next/server";
export async function GET(req: NextRequest) {
const token = req.cookies.get("token")?.value;
if (!token) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const res = await fetch("http://localhost:3001/power", {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) {
return NextResponse.json({ error: "Upstream error" }, { status: res.status });
}
return NextResponse.json(await res.json());
}