feat: implement osu! installation validation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import ky from 'ky';
|
||||
|
||||
const BANCHO_ENDPOINT = 'https://c.ez-pp.farm/';
|
||||
const ENDPOINT = 'https://ez-pp.farm/';
|
||||
|
||||
export const ezppfarm = {
|
||||
ping: async (): Promise<number | undefined> => {
|
||||
@@ -14,4 +15,44 @@ export const ezppfarm = {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
login: async (
|
||||
username: string,
|
||||
password: string
|
||||
): Promise<
|
||||
| {
|
||||
code: number;
|
||||
message: string;
|
||||
user?: {
|
||||
id: number;
|
||||
donor: boolean;
|
||||
name: string;
|
||||
email: string;
|
||||
};
|
||||
}
|
||||
| undefined
|
||||
> => {
|
||||
try {
|
||||
const request = await ky(`${ENDPOINT}login/check`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ username, password }),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'EZPPLauncher',
|
||||
},
|
||||
});
|
||||
if (!request.ok) return undefined;
|
||||
return await request.json<{
|
||||
code: number;
|
||||
message: string;
|
||||
user?: {
|
||||
id: number;
|
||||
donor: boolean;
|
||||
name: string;
|
||||
email: string;
|
||||
};
|
||||
}>();
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user