eksi-sozluk
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -0,1 +1,8 @@ | ||
## [4.0.1](https://github.com/ridvanaltun/eksi-sozluk/compare/v4.0.0...v4.0.1) (2020-09-23) | ||
### Bug Fixes | ||
* **packages:** update all ([8e72ef3](https://github.com/ridvanaltun/eksi-sozluk/commit/8e72ef3904b98bd99c2b678ba8f5f32618ea81bb)) | ||
# [4.0.0](https://github.com/ridvanaltun/eksi-sozluk/compare/v3.0.1...v4.0.0) (2020-06-04) | ||
@@ -2,0 +9,0 @@ |
@@ -25,15 +25,9 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const options = { | ||
endpoint: "m/debe", | ||
}; | ||
const {limit} = usrOptions; | ||
const { limit } = usrOptions; | ||
r(options, ($) => { | ||
r('/m/debe', ($) => { | ||
const status = $.statusCode; | ||
let debe = []; | ||
// success | ||
if (status === 200) { | ||
debe = $("li", "ul.topic-list.partial.mobile") | ||
let debe = $("li", "ul.topic-list.partial.mobile") | ||
.map(function () { | ||
@@ -47,11 +41,9 @@ return { | ||
if (limit) { | ||
debe = debe.slice(0, limit); | ||
} | ||
if (limit) debe = debe.slice(0, limit); | ||
resolve(debe); | ||
} | ||
// not found | ||
if (status === 404) { | ||
} else if(status === 404) { | ||
reject(new e.NotFoundError('Debe not found.')); | ||
} else { | ||
reject(new Error('An unknown error occurred.')); | ||
} | ||
@@ -58,0 +50,0 @@ }); |
@@ -10,31 +10,2 @@ 'use strict'; | ||
/** | ||
* Converts title to actual path. | ||
* | ||
* @param {string} title Title. | ||
* @param {reject} title Reject promise if function fails. | ||
* | ||
* @return {string} Actual path. | ||
* | ||
* @private | ||
* @ignore | ||
*/ | ||
const getActualPath = async (title, reject) => { | ||
try { | ||
const response = await axios.get(urls.base + '/' + title); | ||
const actualPath = response.request.path; | ||
return actualPath; | ||
} catch (err) { | ||
const {status} = err.response; | ||
if (status === 404) { | ||
reject(new e.NotFoundError('Entries not found.')); | ||
} else { | ||
reject(err); | ||
} | ||
} | ||
return false; | ||
}; | ||
/** | ||
* A promise for entries. | ||
@@ -57,16 +28,13 @@ * | ||
const getEntries = (title, usrOptions) => { | ||
return new Promise(async (resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
let {page} = usrOptions; | ||
if (!page) { | ||
page = 1; | ||
} | ||
if (!page) page = 1; | ||
const endpoint = await getActualPath(title, reject) + '?p=' + page; | ||
const endpoint = '/?q=' + title + '&p=' + page; | ||
r({endpoint}, ($) => { | ||
r(endpoint, ($) => { | ||
const status = $.statusCode; | ||
let entries = []; | ||
// success | ||
if (status === 200) { | ||
@@ -96,9 +64,7 @@ $('ul#entry-item-list li').each(function(i, elm) { | ||
}); | ||
resolve(entries); | ||
} | ||
// not found | ||
if (status === 404) { | ||
} else if(status === 404) { | ||
reject(new e.NotFoundError('Entries not found.')); | ||
} else { | ||
reject(new Error('An unknown error occurred.')); | ||
} | ||
@@ -105,0 +71,0 @@ }); |
@@ -25,17 +25,9 @@ 'use strict'; | ||
return new Promise((resolve, reject) => { | ||
const options = { | ||
endpoint: 'entry', | ||
id: entryId, | ||
}; | ||
r(options, ($) => { | ||
r(`/entry/${entryId}`, ($) => { | ||
const status = $.statusCode; | ||
let entry = {}; | ||
// success | ||
if (status === 200) { | ||
const date = d($('ul#entry-item-list li footer div.info a.permalink').text()); | ||
const isEksiseylerExist = $('ul#entry-item-list li').data('seyler-slug') !== ''; | ||
entry = { | ||
const entry = { | ||
author: $('ul#entry-item-list li').data('author'), | ||
@@ -58,9 +50,7 @@ author_id: $('ul#entry-item-list li').data('author-id'), | ||
}; | ||
resolve(entry); | ||
} | ||
// not found | ||
if (status === 404) { | ||
} else if(status === 404) { | ||
reject(new e.NotFoundError('Entry not found.')); | ||
} else { | ||
reject(new Error('An unknown error occurred.')); | ||
} | ||
@@ -67,0 +57,0 @@ }); |
@@ -65,13 +65,10 @@ 'use strict'; | ||
if (!page) { | ||
page = 1; | ||
} | ||
if (!page) page = 1; | ||
const endpoint = 'basliklar/m/tarihte-bugun?year=' + year + '&p=' + page; | ||
const endpoint = '/basliklar/m/tarihte-bugun?year=' + year + '&p=' + page; | ||
r({endpoint}, ($) => { | ||
r(endpoint, ($) => { | ||
const status = $.statusCode; | ||
let titles = []; | ||
// success | ||
if (status === 200) { | ||
@@ -81,3 +78,2 @@ $('ul.topic-list.partial.mobile li').each(function(i, elm) { | ||
const entryCount = $(elm).find('a small').text().trim(); | ||
titles.push({ | ||
@@ -89,9 +85,7 @@ title: clearTitle(title, entryCount), | ||
}); | ||
resolve(titles); | ||
} | ||
// not found | ||
if (status === 404) { | ||
} else if(status === 404) { | ||
reject(new e.NotFoundError('Today in history not found.')); | ||
} else { | ||
reject(new Error('An unknown error occurred.')); | ||
} | ||
@@ -98,0 +92,0 @@ }); |
@@ -64,17 +64,8 @@ 'use strict'; | ||
const options = { | ||
endpoint: 'biri', | ||
id: username, | ||
}; | ||
r(options, ($) => { | ||
r(`/biri/${username}`, ($) => { | ||
const status = $.statusCode; | ||
let user = {}; | ||
// get badges | ||
const {badges, badgePoints} = getKarma($); | ||
// success | ||
if (status === 200) { | ||
user = { | ||
const user = { | ||
username: $('h1#user-profile-title a').text(), | ||
@@ -90,11 +81,8 @@ user_url: urls.user + username, | ||
}; | ||
resolve(user); | ||
} | ||
// not found | ||
if (status === 404) { | ||
} else if(status === 404) { | ||
reject(new e.NotFoundError('User not found.')); | ||
} else { | ||
reject(new Error('An unknown error occurred.')); | ||
} | ||
}); | ||
@@ -101,0 +89,0 @@ }); |
{ | ||
"name": "eksi-sozluk", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Eksi Sozluk NodeJS client.", | ||
@@ -36,22 +36,22 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"axios": "^0.20.0", | ||
"cheerio": "^1.0.0-rc.3", | ||
"moment": "^2.26.0" | ||
"moment": "^2.29.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.3.5", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"commitizen": "^4.1.2", | ||
"commitizen": "^4.2.1", | ||
"coveralls": "^3.1.0", | ||
"cz-conventional-changelog": "^3.2.0", | ||
"eslint": "^7.1.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^7.9.0", | ||
"eslint-config-google": "^0.14.0", | ||
"husky": "^4.2.5", | ||
"jest": "^26.0.1", | ||
"jsdoc": "^3.6.4", | ||
"lint-staged": "^10.2.7", | ||
"husky": "^4.3.0", | ||
"jest": "^26.4.2", | ||
"jsdoc": "^3.6.6", | ||
"lint-staged": "^10.4.0", | ||
"minami": "^1.2.3", | ||
"semantic-release": "^17.0.8" | ||
"semantic-release": "^17.1.2" | ||
}, | ||
@@ -74,6 +74,3 @@ "husky": { | ||
} | ||
}, | ||
"jest": { | ||
"verbose": true | ||
} | ||
} |
{ | ||
"title": "Fetch Debe" | ||
"title": "Debe" | ||
} |
{ | ||
"title": "Fetch Entries" | ||
"title": "Entries" | ||
} |
{ | ||
"title": "Fetch Entry" | ||
"title": "Entry" | ||
} |
{ | ||
"title": "Fetch Debe" | ||
"title": "Today in History" | ||
} |
{ | ||
"title": "Fetch User" | ||
"title": "User" | ||
} |
@@ -6,8 +6,6 @@ 'use strict'; | ||
module.exports = (usrOptions, callback) => { | ||
const endpoint = usrOptions.id ? usrOptions.endpoint + '/' + usrOptions.id : usrOptions.endpoint; | ||
module.exports = (endpoint, callback) => { | ||
const options = { | ||
method: 'get', | ||
url: 'http://eksisozluk.com/' + endpoint, | ||
url: encodeURI('http://eksisozluk.com' + endpoint), | ||
transformResponse: (body) => { | ||
@@ -14,0 +12,0 @@ return cheerio.load(body, { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1622182
90
1460
+ Addedaxios@0.20.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)
Updatedaxios@^0.20.0
Updatedmoment@^2.29.0