Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ NEXT_GROUP_TELEGRAM=TELEGRAM_GROUP_OR_CHANNEL_ID
NEXT_MESSAGE_THREAD_ID=YOUR_MESSAGE_THREAD_ID

API_KEY_AQUIFER=YOUR_AQUIFER_API_KEY
GIT_DOOR43_BEARER_TOKEN=YOUR_GIT_DOOR43_API_KEY
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"editor.formatOnSave": true
},
"files.eol": "\n",
"editor.tabSize": 2
"editor.tabSize": 2,
"i18next.i18nPaths": "d:/Gecraft/level/public/locales"
}
10 changes: 6 additions & 4 deletions components/Project/Download.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import ButtonLoading from 'components/ButtonLoading'
import CheckBox from 'components/CheckBox'
import ListBox from 'components/ListBox'

import gitDoorAxios from '../../lib/axios'

import { newTestamentList, obsStoryVerses, usfmFileNames } from 'utils/config'
import {
compileChapter,
Expand Down Expand Up @@ -295,7 +297,7 @@ function Download({
const repo = parts[4].split('_')[0] + '_tw'
const owner = parts[3]
const newUrl = `${baseUrl}/${owner}/${repo}/archive/master.zip`
const response = await axios.get(newUrl, { responseType: 'arraybuffer' })
const response = await gitDoorAxios.get(newUrl, { responseType: 'arraybuffer' })
const zip = new JSZip()
await zip.loadAsync(response.data)
const newZip = new JSZip()
Expand Down Expand Up @@ -335,7 +337,7 @@ function Download({
usfmFileNames[bookCode]
}`
try {
const response = await axios.get(newUrl)
const response = await gitDoorAxios.get(newUrl)
return response.data
} catch (error) {
console.error('Error fetching original USFM:', error)
Expand All @@ -356,7 +358,7 @@ function Download({
acc[chapter] = 0
return acc
}, {})
const methods = await axios.get('/api/methods')
const methods = await gitDoorAxios.get('/api/methods')
const method = methods.data.find((method) => method.title === project.method)
if (!method?.offline_steps) {
return null
Expand Down Expand Up @@ -384,7 +386,7 @@ function Download({
const url = resourcesUrls[resource]
try {
if (resource === 'obs') {
const response = await axios.get(url, { responseType: 'arraybuffer' })
const response = await gitDoorAxios.get(url, { responseType: 'arraybuffer' })
if (response.status !== 200)
throw new Error(`Failed to fetch OBS archive: ${url}`)

Expand Down
15 changes: 15 additions & 0 deletions lib/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios'

const instance = axios.create()

instance.interceptors.request.use((config) => {
const token = process.env.GIT_DOOR43_BEARER_TOKEN

if (token) {
config.headers.Authorization = `Bearer ${token}`
}

return config
})

export default instance
3 changes: 2 additions & 1 deletion pages/api/git/bible.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios'
import usfm from 'usfm-js'

import axios from '../../../lib/axios'

import { parseChapter } from 'utils/usfmHelper'

/**
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/info.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { tsvToJson } from '@texttree/translation-words-helpers'

import axios from '../../../lib/axios'

/**
* @swagger
* /api/git/info:
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/obs-tn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { tsvToJson } from '@texttree/translation-words-helpers'

import axios from '../../../lib/axios'

import { filterNotes } from 'utils/helper'

/**
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/obs-tq.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { tsvToJson } from '@texttree/translation-words-helpers'

import axios from '../../../lib/axios'

/**
* @swagger
* /api/git/obs-tq:
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/obs-twl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { markRepeatedWords, tsvToJson } from '@texttree/translation-words-helpers'

import axios from '../../../lib/axios'

/**
* @swagger
* /api/git/obs-twl:
Expand Down
2 changes: 1 addition & 1 deletion pages/api/git/obs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios'
import axios from '../../../lib/axios'

import { mdToJson } from 'utils/helper'

Expand Down
2 changes: 1 addition & 1 deletion pages/api/git/ta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios'
import axios from '../../../lib/axios'

/**
* @swagger
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/tn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { tsvToJSON } from '@texttree/tn-quote'

import axios from '../../../lib/axios'

/**
* @swagger
* /api/git/tn:
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/tq.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { tsvToJson } from '@texttree/translation-words-helpers'

import axios from '../../../lib/axios'

/**
* @swagger
* /api/git/tq:
Expand Down
2 changes: 1 addition & 1 deletion pages/api/git/tw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios'
import axios from '../../../lib/axios'

/**
* @swagger
Expand Down
4 changes: 2 additions & 2 deletions pages/api/git/twl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

import { markRepeatedWords, tsvToJson } from '@texttree/translation-words-helpers'

import axios from '../../../lib/axios'

/**
* @swagger
* /api/git/twl:
Expand Down
3 changes: 2 additions & 1 deletion pages/api/git/whole-book.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios'
import usfm from 'usfm-js'

import axios from '../../../lib/axios'

import { parseChapter } from 'utils/usfmHelper'

/**
Expand Down
5 changes: 3 additions & 2 deletions utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import usfm from 'usfm-js'

import { JsonToPdf } from '@texttree/obs-format-convert-rcl'

import gitDoorAxios from '../lib/axios'
import { obsStoryVerses } from './config'

const isServer = typeof window === 'undefined'
Expand Down Expand Up @@ -404,7 +405,7 @@ export const parseManifests = async ({ resources, current_method }) => {
const urlArray = pathname.split('/')
const url = getBaseResourceUrl(urlArray)
const manifestUrl = getBaseResourceUrl(urlArray) + '/manifest.yaml'
const { data } = await axios.get(manifestUrl)
const { data } = await gitDoorAxios.get(manifestUrl)
const manifest = jsyaml.load(data, { json: true })

if (current_method.resources[el]) {
Expand Down Expand Up @@ -474,7 +475,7 @@ export const getCountChaptersAndVerses = async ({ link, book_code }) => {
}

try {
const { data } = await axios.get(link)
const { data } = await gitDoorAxios.get(link)
return calculateChaptersAndVerses(data)
} catch (error) {
return { data: null, error }
Expand Down