Skip to content

Commit

Permalink
fix: search by word (#108)
Browse files Browse the repository at this point in the history
* fix: search by word

* fix: documentation
  • Loading branch information
omarciovsena committed May 22, 2020
1 parent 0b809af commit d1c483d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 5 additions & 7 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,11 @@
"book": {
"abbrev":{"pt":"gn","en":"gn"},
"name":"Gênesis",
"author":"Moisés",
"group":"Pentateuco",
"version":"nvi",
"chapter": {
"number": 1,
"verses": 31
}
"author": "Moisés",
"chapters": 50,
"group": "Pentateuco",
"name": "Gênesis",
"testament": "VT"
},
"chapter": 1,
"number": 1,
Expand Down
7 changes: 4 additions & 3 deletions controllers/verse.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export const search = async (req, res) => {
try {
await saveRequest(req)
const { version, search } = req.body
const bookList = {}
const books = await getBooks()
books.map(book => { bookList[book.abbrev.en] = book })

if (!version) {
return notFound(res, 'Version')
Expand All @@ -121,9 +124,7 @@ export const search = async (req, res) => {
occurrence: verses.length,
version,
verses: verses.map(verse => ({
book: {
abbrev: verse.book.abbrev
},
book: bookList[verse.book.abbrev.en],
chapter: verse.chapter,
number: verse.number,
text: verse.text
Expand Down
1 change: 1 addition & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const genericError = (res, err) => {
console.error('err', err)
return res.status(500).json({
msg: 'Oops! An unexpected error has occurred, create an [issue](https://github.com/marciovsena/bibleapi/issues/new) with the information of this request.',
err
Expand Down

0 comments on commit d1c483d

Please sign in to comment.