mirror of
https://github.com/Nezumi-2711/uptime-monitoring.git
synced 2026-09-22 13:48:31 +00:00
31 lines
567 B
TypeScript
31 lines
567 B
TypeScript
import { getJson, postJson } from "./http";
|
|
|
|
export type AuthUser = {
|
|
id: string;
|
|
email: string;
|
|
};
|
|
|
|
export type SessionResponse = {
|
|
user: AuthUser | null;
|
|
};
|
|
|
|
export type LoginInput = {
|
|
email: string;
|
|
password: string;
|
|
};
|
|
|
|
export function getSession(signal?: AbortSignal) {
|
|
return getJson<SessionResponse>("/api/auth/me", {
|
|
signal,
|
|
credentials: "same-origin",
|
|
});
|
|
}
|
|
|
|
export function login(input: LoginInput) {
|
|
return postJson<SessionResponse>("/api/auth/login", input);
|
|
}
|
|
|
|
export function logout() {
|
|
return postJson<{ ok: true }>("/api/auth/logout");
|
|
}
|