diff options
| author | Fuwn <[email protected]> | 2022-03-24 05:39:37 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-24 05:39:37 -0700 |
| commit | 020762b7cc2bbd7f09a792e744dc4e0c5eaab9eb (patch) | |
| tree | b918ed69978e962dbbb3f5a87b902a54cb616443 /src/index.ts | |
| download | node-senpy-020762b7cc2bbd7f09a792e744dc4e0c5eaab9eb.tar.xz node-senpy-020762b7cc2bbd7f09a792e744dc4e0c5eaab9eb.zip | |
feat: 0.1.0 :star:
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; +}; |