mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-08 00:14:07 +08:00
refactor(types): PSA types
move to shared types (#4774) add types to ape client (#4786)
This commit is contained in:
parent
f456e1e615
commit
65120db1f0
6 changed files with 15 additions and 19 deletions
|
|
@ -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
backend/src/types/types.d.ts
vendored
6
backend/src/types/types.d.ts
vendored
|
|
@ -185,12 +185,6 @@ declare namespace MonkeyTypes {
|
|||
approved: boolean;
|
||||
}
|
||||
|
||||
interface PSA {
|
||||
sticky?: boolean;
|
||||
message: string;
|
||||
level?: number;
|
||||
}
|
||||
|
||||
type ReportTypes = "quote" | "user";
|
||||
|
||||
interface Report {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -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> {
|
||||
|
|
|
|||
8
frontend/src/ts/types/types.d.ts
vendored
8
frontend/src/ts/types/types.d.ts
vendored
|
|
@ -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;
|
||||
|
|
|
|||
8
shared-types/types.d.ts
vendored
8
shared-types/types.d.ts
vendored
|
|
@ -318,4 +318,12 @@ declare namespace SharedTypes {
|
|||
none?: boolean;
|
||||
} & Record<string, boolean>;
|
||||
}
|
||||
|
||||
interface PSA {
|
||||
_id: string;
|
||||
message: string;
|
||||
sticky?: boolean;
|
||||
level?: number;
|
||||
date?: number;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue