Comparing version 1.0.3 to 1.0.4
58
index.js
@@ -1,7 +0,57 @@ | ||
const example = require('./js/example') | ||
const config = require('./config') | ||
const getVersions = require('./js/helpers/get-versions') | ||
const doSearchRequests = require('./js/http/search/do-search-requests') | ||
const doVerseRequests = require('./js/http/verse/do-verse-requests') | ||
const urlSearchBuilder = require('./js/http/search/url-search-builder') | ||
const urlVerseBuilder = require('./js/http/verse/url-verse-builder') | ||
const errors = require('./errors') | ||
const main = () => { | ||
return example() | ||
class BibleApi { | ||
constructor() { | ||
this.defaultVersions = getVersions() | ||
this.resultsPerPage = 50 | ||
} | ||
checkApiKey() { | ||
if (this.apiKey == null) throw errors.generic.apiKey() | ||
} | ||
getVersions() { | ||
return config.publicVersions | ||
} | ||
setApiKey(apiKey) { | ||
if (typeof apiKey !== 'string') throw errors.type.apiKey() | ||
this.apiKey = apiKey.trim() | ||
} | ||
setDefaultVersions(versions) { | ||
this.defaultVersions = getVersions(versions, this.defaultVersions) | ||
} | ||
setNumberOfSearchResultsPerPage(resultsPerPage) { | ||
if (!Number.isInteger(resultsPerPage) || resultsPerPage < 1) throw errors.type.resultsPerPage() | ||
this.resultsPerPage = resultsPerPage | ||
} | ||
getReference(reference, versions) { | ||
if (typeof reference !== 'string') throw errors.type.reference() | ||
this.checkApiKey() | ||
versions = getVersions(versions, this.defaultVersions) | ||
const urls = urlVerseBuilder(this.apiKey, versions, reference) | ||
if (urls == null) throw errors.generic.reference(reference) | ||
return doVerseRequests(urls, versions, reference) | ||
} | ||
search(query, versions, offset = 0) { | ||
if (typeof query !== 'string') throw errors.type.query() | ||
if (!Number.isInteger(offset) || offset < 0) throw errors.type.offset() | ||
this.checkApiKey() | ||
versions = getVersions(versions, this.defaultVersions) | ||
const urls = urlSearchBuilder(this.apiKey, versions, query, offset, this.resultsPerPage) | ||
return doSearchRequests(urls, versions) | ||
} | ||
} | ||
module.exports = main | ||
module.exports = new BibleApi() |
{ | ||
"name": "bible-api", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Bible API that relies on the Digital Bible Toolkit at www.digitalbibleplatform.com", | ||
@@ -12,7 +12,10 @@ "author": "danday74", | ||
"build": "npm-run-all test enforcer", | ||
"prepush": "npm test" | ||
"prepush": "npm run build" | ||
}, | ||
"dependencies": { | ||
"chapter-and-verse": "^1.0.6", | ||
"lodash": "^4.17.5" | ||
"axios": "^0.17.1", | ||
"chapter-and-verse": "^2.0.2", | ||
"lodash": "^4.17.5", | ||
"type-check": "^0.3.2", | ||
"url": "^0.11.0" | ||
}, | ||
@@ -25,4 +28,7 @@ "devDependencies": { | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.0.0", | ||
"npm-run-all": "^4.1.2" | ||
"mocha": "^5.0.1", | ||
"nock": "^9.1.6", | ||
"npm-run-all": "^4.1.2", | ||
"prettyjson": "^1.2.1", | ||
"sinon": "^4.3.0" | ||
}, | ||
@@ -29,0 +35,0 @@ "keywords": [], |
@@ -17,2 +17,4 @@ # bible-api | ||
TODO .. Development in progress, docs coming real soon | ||
TODO .. Development in progress, this may take some time! | ||
@@ -0,1 +1,2 @@ | ||
// process.env.DEBUG = 'nock.*' | ||
process.env.NODE_ENV = 'test' |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
33942
34
892
20
5
10
6
1
+ Addedaxios@^0.17.1
+ Addedtype-check@^0.3.2
+ Addedurl@^0.11.0
+ Addedaxios@0.17.1(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedchapter-and-verse@2.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addedurl@0.11.4(transitive)
- Removedchapter-and-verse@1.1.3(transitive)
Updatedchapter-and-verse@^2.0.2