ディレクトリ再編
This commit is contained in:
parent
cb924ff92b
commit
85d471efbb
45 changed files with 204 additions and 41 deletions
25
src/backend/services/misskey.ts
Normal file
25
src/backend/services/misskey.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import axios from 'axios';
|
||||
import _const from '../const';
|
||||
|
||||
export const ua = `Mozilla/5.0 misshaialertBot/${_const.version} +https://github.com/Xeltica/misshaialert Node/${process.version}`;
|
||||
|
||||
axios.defaults.headers['User-Agent'] = ua;
|
||||
|
||||
axios.defaults.validateStatus = (stat) => stat < 500;
|
||||
|
||||
export const api = <T = Record<string, unknown>>(host: string, endpoint: string, arg: Record<string, unknown>, i?: string): Promise<T> => {
|
||||
const a = { ...arg };
|
||||
if (i) {
|
||||
a.i = i;
|
||||
}
|
||||
return axios.post<T>(`https://${host}/api/${endpoint}`, a).then(res => res.data);
|
||||
};
|
||||
|
||||
export const apiAvailable = async (host: string, i: string): Promise<boolean> => {
|
||||
try {
|
||||
const res = await api(host, 'i', {}, i);
|
||||
return !res.error;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue