refactor: repositories (#28)

* cleanup unnecessary mocks

* refactor document storage location

* remove unused function

* move ownership to document types to repo package

* move types and mappers to repo package

* refactor sets to own package
This commit is contained in:
Hayden 2022-09-27 15:52:13 -08:00 committed by GitHub
parent 2e82398e5c
commit 343290a55a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 3169 additions and 3160 deletions

View file

@ -1,24 +1,11 @@
import { BaseAPI, route } from "./base";
export type LoginResult = {
token: string;
expiresAt: string;
};
import { ApiSummary, TokenResponse, UserRegistration } from "./types/data-contracts";
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[];
@ -28,11 +15,11 @@ export type StatusResult = {
export class PublicApi extends BaseAPI {
public status() {
return this.http.get<StatusResult>({ url: route("/status") });
return this.http.get<ApiSummary>({ url: route("/status") });
}
public login(username: string, password: string) {
return this.http.post<LoginPayload, LoginResult>({
return this.http.post<LoginPayload, TokenResponse>({
url: route("/users/login"),
body: {
username,
@ -41,7 +28,7 @@ export class PublicApi extends BaseAPI {
});
}
public register(body: RegisterPayload) {
return this.http.post<RegisterPayload, LoginResult>({ url: route("/users/register"), body });
public register(body: UserRegistration) {
return this.http.post<UserRegistration, TokenResponse>({ url: route("/users/register"), body });
}
}