mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
style: apply prettier across the tree
One-shot prettier pass so the new format:check gate starts from a clean baseline. Formatting only — no behaviour change. Generator-owned and vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
1 parent
b3fea2ef59
commit
1f4ba5939d
1000 files changed
+12130
-8385
No files matched your search
@@ -79,7 +79,10 @@ export const GET = apiHandler(async (request: NextRequest) => {
|
||||
// Guard against an off-spec token body without `x_user_id`: persisting the
|
||||
// string "undefined" as the member id would break every later data read
|
||||
// (`/v3/users/undefined/...`) with no clear cause.
|
||||
if (typeof tokens.x_user_id !== "number" || !Number.isFinite(tokens.x_user_id)) {
|
||||
if (
|
||||
typeof tokens.x_user_id !== "number" ||
|
||||
!Number.isFinite(tokens.x_user_id)
|
||||
) {
|
||||
return ERR("token");
|
||||
}
|
||||
const polarUserId = String(tokens.x_user_id);
|
||||
|
||||
@@ -48,10 +48,7 @@ export const GET = apiHandler(async () => {
|
||||
|
||||
const creds = await getPolarClientCredentials(user.id);
|
||||
if (!creds) {
|
||||
return apiError(
|
||||
"Polar integration is not configured on this server.",
|
||||
400,
|
||||
);
|
||||
return apiError("Polar integration is not configured on this server.", 400);
|
||||
}
|
||||
|
||||
const state = mintSignedState("polar", user.id);
|
||||
|
||||
@@ -47,7 +47,11 @@ describe("POST /api/polar/disconnect", () => {
|
||||
});
|
||||
|
||||
it("rate-limits the disconnect surface (429 on bucket exhaustion)", async () => {
|
||||
rateLimitMock.mockResolvedValue({ allowed: false, remaining: 0, resetAt: 0 });
|
||||
rateLimitMock.mockResolvedValue({
|
||||
allowed: false,
|
||||
remaining: 0,
|
||||
resetAt: 0,
|
||||
});
|
||||
const res = await post();
|
||||
expect(res.status).toBe(429);
|
||||
// The user lookup never runs once the bucket is exhausted.
|
||||
|
||||
@@ -14,9 +14,15 @@ export const dynamic = "force-dynamic";
|
||||
const POLAR_USERS_BASE = "https://www.polaraccesslink.com/v3/users";
|
||||
const TIMEOUT_MS = 5_000;
|
||||
|
||||
function categoriseHttpStatus(status: number): { code: string; message: string } {
|
||||
function categoriseHttpStatus(status: number): {
|
||||
code: string;
|
||||
message: string;
|
||||
} {
|
||||
if (status === 401 || status === 403) {
|
||||
return { code: "credentials_rejected", message: "Polar rejected the token" };
|
||||
return {
|
||||
code: "credentials_rejected",
|
||||
message: "Polar rejected the token",
|
||||
};
|
||||
}
|
||||
if (status === 429) {
|
||||
return { code: "rate_limited", message: "Polar rate-limited the request" };
|
||||
@@ -40,7 +46,9 @@ export const POST = apiHandler(async () => {
|
||||
|
||||
const connection = await getPolarConnection(user.id);
|
||||
if (!connection) {
|
||||
return apiError("Polar not connected", 422, { errorCode: "not_configured" });
|
||||
return apiError("Polar not connected", 422, {
|
||||
errorCode: "not_configured",
|
||||
});
|
||||
}
|
||||
|
||||
const start = performance.now();
|
||||
|
||||
Reference in new issue
Block a user