2022-09-09 14:46:53 -08:00
|
|
|
import { BaseAPI, route } from "./base";
|
2023-03-22 21:52:25 -08:00
|
|
|
import { ApiSummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
|
2022-09-01 14:32:03 -08:00
|
|
|
|
2022-09-03 18:42:03 -08:00
|
|
|
export type StatusResult = {
|
|
|
|
health: boolean;
|
|
|
|
versions: string[];
|
|
|
|
title: string;
|
|
|
|
message: string;
|
|
|
|
};
|
|
|
|
|
2022-09-01 14:32:03 -08:00
|
|
|
export class PublicApi extends BaseAPI {
|
2022-09-03 18:42:03 -08:00
|
|
|
public status() {
|
2022-09-27 15:52:13 -08:00
|
|
|
return this.http.get<ApiSummary>({ url: route("/status") });
|
2022-09-03 18:42:03 -08:00
|
|
|
}
|
|
|
|
|
2023-03-22 21:52:25 -08:00
|
|
|
public login(username: string, password: string, stayLoggedIn = false) {
|
|
|
|
return this.http.post<LoginForm, TokenResponse>({
|
2022-09-09 14:46:53 -08:00
|
|
|
url: route("/users/login"),
|
2022-09-08 22:05:23 -08:00
|
|
|
body: {
|
|
|
|
username,
|
|
|
|
password,
|
2023-03-22 21:52:25 -08:00
|
|
|
stayLoggedIn,
|
2022-09-08 22:05:23 -08:00
|
|
|
},
|
2022-09-01 17:52:40 -08:00
|
|
|
});
|
2022-09-01 14:32:03 -08:00
|
|
|
}
|
|
|
|
|
2022-09-27 15:52:13 -08:00
|
|
|
public register(body: UserRegistration) {
|
|
|
|
return this.http.post<UserRegistration, TokenResponse>({ url: route("/users/register"), body });
|
2022-09-01 14:32:03 -08:00
|
|
|
}
|
|
|
|
}
|