Appearance
BiblesModule
The BiblesModule
is an integral part of NestKit and provides a comprehensive API to facilitate smooth interactions with various Bible versions and their associated content. With this module, developers can access several Bibles, such as NIV or BTI, and their respective books, chapters, and verses.
API Hierarchy
The following describes the hierarchical structure of the Bible API:
Bible Entity
The Bible
entity is the main entity, stored in the bibles
database.
BibleBook Entity
Each Bible
entity contains several BibleBook
entities. A BibleBook
represents a book within a particular Bible version.
BibleChapter Entity
Each BibleBook
contains several BibleChapter
entities, each representing a chapter in a specific book.
BibleVerse Entity
Each BibleChapter
contains several BibleVerse
entities, each representing a verse in a specific chapter of a book.
Bibles Service
The Bible Module also includes a BiblesService
that can interface with the Bible and its content. This service allows you to retrieve Bible versions, books, chapters, and verses from the database.
Brands Resolver
the BiblesModule
includes a critical component known as theBiblesResolver
. This component is designed to aid in the retrieval of Bible data and content using GraphQL.
How to install BiblesModule to my app
To install the BiblesModule
into your main AppModule
, you need to include it in the imports array of your AppModule
.
ts
// src/modules/app.module.ts
import { Module } from '@nestjs/common';
import { BiblesModule } from '@deeepvision/nest-kit/dist/modules/bibles';
// Other imports...
@Module({
imports: [
BiblesModule,
// Other modules...
],
controllers: [/* ... */],
providers: [/* ... */],
})
export class AppModule {}
Books IDs structure
In BibleModule
, each verse has a specific ID structure. For instance, the verse Exo. 1:2
from the NIV Bible would have the ID NIV:EXO:1:2
. Here's a breakdown of the ID parts:
KJV
: Bible TokenEXO
: Book Token1
: Chapter Number2
: Verse Number
Here is the list of supported book ids:
plaintext
GEN - Genesis
EXO - Exodus
LEV - Leviticus
NUM - Numbers
DEU - Deuteronomy
JOS - Joshua
JDG - Judges
RUT - Ruth
1SA - 1 Samuel
2SA - 2 Samuel
1KI - 1 Kings
2KI - 2 Kings
1CH - 1 Chronicles
2CH - 2 Chronicles
EZR - Ezra
NEH - Nehemiah
EST - Esther
JOB - Job
PSA - Psalms
PRO - Proverbs
ECC - Ecclesiastes
SNG - Song of Solomon
ISA - Isaiah
JER - Jeremiah
LAM - Lamentations
EZK - Ezekiel
DAN - Daniel
HOS - Hosea
JOL - Joel
AMO - Amos
OBA - Obadiah
JON - Jonah
MIC - Micah
NAM - Nah.
HAB - Habakkuk
ZEP - Zephaniah
HAG - Haggai
ZEC - Zechariah
MAL - Malachi
MAT - Matthew
MRK - Mark
LUK - Luke
JHN - John
ACT - Acts
ROM - Romans
1CO - 1 Corinthians
2CO - 2 Corinthians
GAL - Galatians
EPH - Ephesians
PHP - Philippians
COL - Colossians
1TH - 1 Thessalonians
2TH - 2 Thessalonians
1TI - 1 Timothy
2TI - 2 Timothy
TIT - Titus
PHM - Philemon
HEB - Hebrews
JAS - James
1PE - 1 Peter
2PE - 2 Peter
1JN - 1 John
2JN - 2 John
3JN - 3 John
JUD - Jude
REV - Revelation
How to get bible by ID
Use the getOne()
method from your BiblesService
to get a bible by id in other parts of your application.
ts
const bible = await this.biblesService.getOne('NIV');
Use the getOneOrFail()
method to retrieve a bible by id or throw an error if the bible is not found.
ts
const brand = await this.brandsService.getOneOrFail('NIV', ctx);
Fetch bible by id with GraphQL
Here's an example GraphQL query to fetch bible by id.
How to get bibles list
Use the getMany()
method in other parts of your application to retrieve a list of bibles.
ts
const [bibles, meta] = await this.biblesService.getMany({
filter: {
...
},
orderBy: BiblesOrderBy.title_ASC,
});
See BiblesFilter
and BiblesOrderBy
for more information on how to filter and order bibles.
Fetch bibles list with GraphQL
Here's an example GraphQL query to fetch bibles.
How to get bible books list
Use the getBooks()
method in other parts of your application to retrieve a list of bible books.
ts
const books = await this.biblesService.getBooks('NIV');
Fetch bible books list with GraphQL
Here's an example GraphQL query to fetch bible books.
How to get bible book by ID
Use the getBook()
method from your BiblesService
to get a bible book by id in other parts of your application.
ts
const book = await this.biblesService.getBook('NIV:GEN');
Use the getOneOrFail()
method to retrieve a bible book by id or throw an error if it's not found.
ts
const book = await this.biblesService.getBookOrFail('NIV:GEN', ctx);
Fetch bible book by id with GraphQL
Here's an example GraphQL query to fetch bible book by id.
How to get bible book chapters list
Use the getChapters()
method in other parts of your application to retrieve a list of bible book chapters.
ts
const chapters = await this.biblesService.getChapters('NIV:GEN');
How to get bible verses list
Use the getVerses()
method in other parts of your application to retrieve a list of bible verses.
ts
const verses = await this.biblesService.getVerses({
bibleBookId: 'NIV:GEN',
chapter: 1,
});
Fetch bible verses in chapter with GraphQL
Here's an example GraphQL query to fetch bible verses.
How to get bible verse by ID
Use the getVerse()
method from your BiblesService
to get a bible verse by id in other parts of your application.
ts
const verse = await this.biblesService.getVerse('NIV:GEN:1:1');
Use the getVerseOrFail()
method to retrieve a bible verse by id or throw an error if it's not found.
ts
const verse = await this.biblesService.getVersekOrFail('NIV:GEN:1:1', ctx);
Also, you can use thegetVerseByPassage()
method from your BiblesService
to get a bible verse by passage in other parts of your application.
ts
const verse = await this.biblesService.getVerse('Gen. 1:1');
Fetch bible verse by ID with GraphQL
Here's an example GraphQL query to fetch bible verse by id.
How to decode bible passage
The BiblesService
within the BiblesModule
includes a powerful method: decodePassage
. This method facilitates the highlighting of verses and can be called as follows:
ts
const result = await this.bibleService.decodePassage({
bibleId: 'NIV',
passage: 'Gen. 1:1-3,6; Ex. 1:2'
});
In this example, decodePassage
accepts two parameters: a bibleId
representing the specific version of the Bible (e.g., NIV
for New International Version) and a passage
representing the passage to be decoded.
The method returns a DecodedBiblePassage
object, which includes a string of the passage and an array of DecodedBiblePassagePart
objects, each representing a group of verses.
ts
export class DecodedBiblePassage {
@Field()
passage!: string;
@Field(() => [DecodedBiblePassagePart])
parts!: DecodedBiblePassagePart[];
}
A DecodedBiblePassagePart
object groups verses together that are from the same book. This division into separate parts is helpful when displaying verses from different books in distinct sections on the user interface.
ts
export class DecodedBiblePassagePart {
@Field()
passage!: string;
@Field(() => [BibleVerse])
verses!: BibleVerse[];
}
Each DecodedBiblePassagePart
contains a string of the passage and an array of BibleVerse
objects, each representing a verse within the passage. This structure allows for easy handling and displaying of decoded Bible passages.
ts
let content = '';
for (const part of result.parts) {
for (const verse of verses) {
content += `${verse.verseNumber}. ${verse.text}\n`;
}
content += `${part.passage}\n`;
}
plaintext
1. In the beginning God created the heaven and the earth.
2. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
3. And God said, Let there be light: and there was light.
...
6. And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.
Gen. 1:1-3,6
2. Reuben, Simeon, Levi, and Judah,
Ex. 1:2
Fetch decoded verse with GraphQL
Here's an example GraphQL query to fetch decoded bible verse.