mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 21:16:31 +00:00
75c633dcb5
* dummy commit * cleanup workflows * setup and run eslint * add linter to CI * use eslint for formatting * reorder rules * drop editor config
47 lines
920 B
TypeScript
47 lines
920 B
TypeScript
import { BaseAPI, route } from "./base";
|
|
|
|
export type LoginResult = {
|
|
token: string;
|
|
expiresAt: string;
|
|
};
|
|
|
|
export type LoginPayload = {
|
|
username: string;
|
|
password: string;
|
|
};
|
|
|
|
export type RegisterPayload = {
|
|
user: {
|
|
email: string;
|
|
password: string;
|
|
name: string;
|
|
};
|
|
groupName: string;
|
|
};
|
|
|
|
export type StatusResult = {
|
|
health: boolean;
|
|
versions: string[];
|
|
title: string;
|
|
message: string;
|
|
};
|
|
|
|
export class PublicApi extends BaseAPI {
|
|
public status() {
|
|
return this.http.get<StatusResult>({ url: route("/status") });
|
|
}
|
|
|
|
public login(username: string, password: string) {
|
|
return this.http.post<LoginPayload, LoginResult>({
|
|
url: route("/users/login"),
|
|
body: {
|
|
username,
|
|
password,
|
|
},
|
|
});
|
|
}
|
|
|
|
public register(body: RegisterPayload) {
|
|
return this.http.post<RegisterPayload, LoginResult>({ url: route("/users/register"), body });
|
|
}
|
|
}
|