Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

386 B
Raw Blame
export type ApiKeyExpiry =
  | { status: "never" }
  | { status: "active" | "expired"; date: Date };

export function getApiKeyExpiry(
  expiresAt: Date | string | null | undefined,
  now: number = Date.now(),
): ApiKeyExpiry {
  if (!expiresAt) return { status: "never" };

  const date = new Date(expiresAt);
  return { status: date.getTime() <= now ? "expired" : "active", date };
}