Skip to content

Commit

Permalink
refactor(types): PSA types
Browse files Browse the repository at this point in the history
move to shared types (#4774)
add types to ape client (#4786)
  • Loading branch information
Miodec committed Feb 7, 2024
1 parent f456e1e commit 65120db
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
6 changes: 4 additions & 2 deletions backend/src/dal/psa.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as db from "../init/db";

export async function get(): Promise<MonkeyTypes.PSA[]> {
return await db.collection<MonkeyTypes.PSA>("psa").find().toArray();
type PSA = MonkeyTypes.WithObjectId<SharedTypes.PSA>;

export async function get(): Promise<PSA[]> {
return await db.collection<PSA>("psa").find().toArray();
}
6 changes: 0 additions & 6 deletions backend/src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ declare namespace MonkeyTypes {
approved: boolean;
}

interface PSA {
sticky?: boolean;
message: string;
level?: number;
}

type ReportTypes = "quote" | "user";

interface Report {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/ape/endpoints/psas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class Psas {
this.httpClient = httpClient;
}

async get(): Ape.EndpointResponse {
async get(): Ape.EndpointResponse<SharedTypes.PSA[]> {
return await this.httpClient.get(BASE_PATH);
}
}
4 changes: 2 additions & 2 deletions frontend/src/ts/elements/psa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function setMemory(id: string): void {
window.localStorage.setItem("confirmedPSAs", JSON.stringify(list));
}

async function getLatest(): Promise<MonkeyTypes.PSA[] | null> {
async function getLatest(): Promise<SharedTypes.PSA[] | null> {
const response = await Ape.psas.get();

if (response.status === 500) {
Expand Down Expand Up @@ -54,7 +54,7 @@ async function getLatest(): Promise<MonkeyTypes.PSA[] | null> {
} else if (response.status !== 200) {
return null;
}
return response.data as MonkeyTypes.PSA[];
return response.data;
}

export async function show(): Promise<void> {
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/ts/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,6 @@ declare namespace MonkeyTypes {
textSplit?: string[];
}

interface PSA {
sticky?: boolean;
message: string;
_id: string;
level?: number;
date?: number;
}

interface ThemeColors {
bg: string;
main: string;
Expand Down
8 changes: 8 additions & 0 deletions shared-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,12 @@ declare namespace SharedTypes {
none?: boolean;
} & Record<string, boolean>;
}

interface PSA {
_id: string;
message: string;
sticky?: boolean;
level?: number;
date?: number;
}
}

0 comments on commit 65120db

Please sign in to comment.