@technoeren/tdk-api
Advanced tools
Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "@technoeren/tdk-api", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"types": "index.js", | ||
"files": [ | ||
@@ -26,2 +25,3 @@ "dist", | ||
}, | ||
"repository": { | ||
@@ -28,0 +28,0 @@ "type": "git", |
@@ -1,69 +0,7 @@ | ||
import axios from "axios"; | ||
import { InvalidWord, ValueNotFound } from "../errors/tdk-errors"; | ||
import { IGetWord } from '../typings'; | ||
export class TDKAPI { | ||
constructor() {} | ||
public async getWord(word: string): Promise<IGetWord> { | ||
if (word.trim().length < 1) throw new InvalidWord(); | ||
let response = await axios.get( | ||
`https://sozluk.gov.tr/gts?ara=${encodeURI(word)}` | ||
); | ||
if (response.data.error) throw new ValueNotFound(); | ||
let anlamlar: any = []; | ||
for (const element of response.data[0].anlamlarListe) { | ||
anlamlar.push({ | ||
anlam: element.anlam, | ||
ornek: element.orneklerListe ? element.orneklerListe[0].ornek : null, | ||
}); | ||
} | ||
return { | ||
anlamlar, | ||
atasozu_deyim: response.data[0].atasozu | ||
? response.data[0].atasozu[0].madde | ||
: null, | ||
}; | ||
getWord(word: string): string { | ||
return word; | ||
} | ||
public async isExistWord(word: string): Promise<boolean> { | ||
if (word.trim().length < 1) throw new InvalidWord(); | ||
let response = await axios.get( | ||
`https://sozluk.gov.tr/gts?ara=${encodeURI(word)}` | ||
); | ||
return response.data.length > 0 ? true : false; | ||
} | ||
public async getProVerbs(value: string): Promise<any> { | ||
if (value.trim().length < 1) throw new InvalidWord(); | ||
let response = await axios.get( | ||
`https://sozluk.gov.tr/atasozu?ara=${encodeURI(value)}` | ||
); | ||
if (response.data.error) throw new ValueNotFound(); | ||
let proverbs: any = [{ soz: '', anlam: '', tur: ''}]; | ||
for (const element of response.data) { | ||
proverbs.push({ | ||
soz: element.sozum, | ||
tur: element.turu2, | ||
anlam: element.anlami, | ||
}); | ||
} | ||
return { proverbs }; | ||
} | ||
} | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7634
19
140