homebox/frontend/lib/api/public.ts
Hayden b77c9be36f
chore: bump deps (#810)
* bump prettier/eslint-plugin

* bump nuxt pwa

* use typed imports

* set vue version to fix layout errors

* disable import
2024-03-01 09:08:14 -09:00

30 lines
793 B
TypeScript

import { BaseAPI, route } from "./base";
import type { APISummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
export type StatusResult = {
health: boolean;
versions: string[];
title: string;
message: string;
};
export class PublicApi extends BaseAPI {
public status() {
return this.http.get<APISummary>({ url: route("/status") });
}
public login(username: string, password: string, stayLoggedIn = false) {
return this.http.post<LoginForm, TokenResponse>({
url: route("/users/login"),
body: {
username,
password,
stayLoggedIn,
},
});
}
public register(body: UserRegistration) {
return this.http.post<UserRegistration, TokenResponse>({ url: route("/users/register"), body });
}
}