Socket
Socket
Sign inDemoInstall

@technoeren/tdk-api

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@technoeren/tdk-api - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

src/helpers/errors.ts

15

package.json
{
"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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc