From 020762b7cc2bbd7f09a792e744dc4e0c5eaab9eb Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 24 Mar 2022 05:39:37 -0700 Subject: feat: 0.1.0 :star: --- src/index.ts | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/index.ts (limited to 'src') 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; +}; -- cgit v1.2.3