@technoeren/tdk-api
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "@technoeren/tdk-api", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"main": "app.js", | ||
@@ -15,3 +15,4 @@ "repository": "git@github.com:technoeren13/tdk-api.git", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"prepare": "husky install" | ||
"prepare": "husky install", | ||
"publish": "npm version patch && nğm publish" | ||
}, | ||
@@ -33,7 +34,4 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@technoeren/tdk-api": "^0.0.5", | ||
"@types/node": "^17.0.21", | ||
"typescript": "^4.5.5" | ||
}, | ||
"dependencies": { | ||
"@technoeren/tdk-api": "^0.0.1", | ||
"axios": "^0.26.0", | ||
@@ -43,4 +41,5 @@ "husky": "^7.0.4", | ||
"prettier": "^2.5.1", | ||
"ts-node": "^10.5.0" | ||
} | ||
"typescript": "^4.5.5" | ||
}, | ||
"dependencies": {} | ||
} |
import axios from "axios"; | ||
import { InvalidWord, ValueNotFound } from "./helpers/errors"; | ||
@@ -6,11 +7,60 @@ export class TDKAPI { | ||
public async getWord(word: string) { | ||
let response = (await axios.get(`https://sozluk.gov.tr/gts?ara=${word}`)) | ||
.data[0]; | ||
public async getWord(word: string): Promise<boolean | object> { | ||
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: [response.anlamlarListe], | ||
atasozu: response.atasozu ? response.atasozu[0].madde : null, | ||
anlamlar, | ||
atasozu_deyim: response.data[0].atasozu | ||
? response.data[0].atasozu[0].madde | ||
: null, | ||
}; | ||
} | ||
public async checkWord(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)}` | ||
); | ||
if (response.data.length > 0) return true; | ||
return false; | ||
} | ||
public async getProVerbs(value: string) { | ||
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 = []; | ||
for (const element of response.data) { | ||
proverbs.push({ | ||
soz: element.sozum, | ||
tur: element.turu2, | ||
anlam: element.anlami, | ||
}); | ||
} | ||
return { proverbs }; | ||
} | ||
} |
@@ -6,3 +6,3 @@ import { TDKAPI } from "./app"; | ||
async function run() { | ||
await api.getWord("baklava").then((a) => { | ||
await api.getWord("esenlik").then((a) => { | ||
console.log(a); | ||
@@ -9,0 +9,0 @@ }); |
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
4006
0
7
93
7
- Removed@technoeren/tdk-api@^0.0.1
- Removedaxios@^0.26.0
- Removedhusky@^7.0.4
- Removednodemon@^2.0.15
- Removedprettier@^2.5.1
- Removedts-node@^10.5.0
- Removed@cspotcode/source-map-support@0.8.1(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.9(transitive)
- Removed@technoeren/tdk-api@0.0.1(transitive)
- Removed@tsconfig/node10@1.0.11(transitive)
- Removed@tsconfig/node12@1.0.11(transitive)
- Removed@tsconfig/node14@1.0.3(transitive)
- Removed@tsconfig/node16@1.0.4(transitive)
- Removed@types/node@22.7.4(transitive)
- Removedacorn@8.12.1(transitive)
- Removedacorn-walk@8.3.4(transitive)
- Removedanymatch@3.1.3(transitive)
- Removedarg@4.1.3(transitive)
- Removedaxios@0.26.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbinary-extensions@2.3.0(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@3.0.3(transitive)
- Removedchokidar@3.6.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcreate-require@1.1.1(transitive)
- Removeddebug@3.2.7(transitive)
- Removeddiff@4.0.2(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedfsevents@2.3.3(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhusky@7.0.4(transitive)
- Removedignore-by-default@1.0.1(transitive)
- Removedis-binary-path@2.1.0(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedmake-error@1.3.6(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedms@2.1.3(transitive)
- Removednodemon@2.0.22(transitive)
- Removednormalize-path@3.0.0(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedprettier@2.8.8(transitive)
- Removedpstree.remy@1.1.8(transitive)
- Removedreaddirp@3.6.0(transitive)
- Removedsemver@5.7.27.0.0(transitive)
- Removedsimple-update-notifier@1.1.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedtouch@3.1.1(transitive)
- Removedts-node@10.9.2(transitive)
- Removedtypescript@5.6.2(transitive)
- Removedundefsafe@2.0.5(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedv8-compile-cache-lib@3.0.1(transitive)
- Removedyn@3.1.1(transitive)