Files
HealthLog/src/app/api/withings/disconnect/route.ts
T
Marc-André Bombeck 65e0cba0bf refactor(integrations): start and end every OAuth connection through the kit
Minting the state, building the consent URL and dropping a grant each had a
copy per provider route. The routes keep their auth, rate limits and
redirects and hand the rest to one implementation, which the managed-profile
routes reuse.
2026-10-21 19:49:06 +02:00

19 lines
634 B
TypeScript

import { apiHandler, requireAuth } from "@/lib/api-handler";
import { disconnectOAuth } from "@/lib/integrations/oauth-kit/disconnect";
import { apiSuccess, apiError } from "@/lib/api-response";
import { annotate } from "@/lib/logging/context";
/**
* Disconnect Withings integration for the current user.
*/
export const POST = apiHandler(async () => {
const { user } = await requireAuth();
annotate({ action: { name: "withings.disconnect" } });
if ((await disconnectOAuth("withings", user.id)) === "not_connected") {
return apiError("No Withings connection", 404);
}
return apiSuccess({ disconnected: true });
});