diff options
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..e292d53 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,58 @@ +export const SENPY_CLUB_API_BASE_URl = "https://api.senpy.club"; +export const SENPY_CLUB_API_CURRENT_VERSION = 2; +export const SENPY_CLUB_API_URl = `${SENPY_CLUB_API_BASE_URl}/v${SENPY_CLUB_API_CURRENT_VERSION}`; + +export interface Random { + readonly language: string; + readonly image: string; +} + +export const languages = (): string[] => { + let response; + + fetch(`${SENPY_CLUB_API_URl}/languages`) + .then((api) => api.json()) + .then((api) => { + response = api; + }); + + return response; +}; + +export const language = (language: string): string[] => { + let response; + + fetch(`${SENPY_CLUB_API_URl}/language/${language}`) + .then((api) => api.json()) + .then((api) => { + response = api; + }); + + return response; +}; + +export const random = (): Random => { + let response; + + fetch(`${SENPY_CLUB_API_URl}/random`) + .then((api) => api.json()) + .then((api) => { + response = api; + }); + + return response; +}; + +export const status = (): boolean => { + let response; + + fetch(`${SENPY_CLUB_API_URl}`) + .then(() => { + response = true; + }) + .catch(() => { + response = false; + }); + + return response; +}; |