Skip to content

Commit e4ef053

Browse files
authored
Merge pull request #768 from hiscoder-com/fix-valyukhov-404-error-gitdoor43
Fix 404 error gitdoor43
2 parents d3ec3ea + f31ca27 commit e4ef053

17 files changed

Lines changed: 48 additions & 26 deletions

File tree

.env.local.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ NEXT_GROUP_TELEGRAM=TELEGRAM_GROUP_OR_CHANNEL_ID
2121
NEXT_MESSAGE_THREAD_ID=YOUR_MESSAGE_THREAD_ID
2222

2323
API_KEY_AQUIFER=YOUR_AQUIFER_API_KEY
24+
GIT_DOOR43_BEARER_TOKEN=YOUR_GIT_DOOR43_API_KEY

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"editor.formatOnSave": true
1313
},
1414
"files.eol": "\n",
15-
"editor.tabSize": 2
15+
"editor.tabSize": 2,
16+
"i18next.i18nPaths": "d:/Gecraft/level/public/locales"
1617
}

components/Project/Download.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import ButtonLoading from 'components/ButtonLoading'
1515
import CheckBox from 'components/CheckBox'
1616
import ListBox from 'components/ListBox'
1717

18+
import gitDoorAxios from '../../lib/axios'
19+
1820
import { newTestamentList, obsStoryVerses, usfmFileNames } from 'utils/config'
1921
import {
2022
compileChapter,
@@ -295,7 +297,7 @@ function Download({
295297
const repo = parts[4].split('_')[0] + '_tw'
296298
const owner = parts[3]
297299
const newUrl = `${baseUrl}/${owner}/${repo}/archive/master.zip`
298-
const response = await axios.get(newUrl, { responseType: 'arraybuffer' })
300+
const response = await gitDoorAxios.get(newUrl, { responseType: 'arraybuffer' })
299301
const zip = new JSZip()
300302
await zip.loadAsync(response.data)
301303
const newZip = new JSZip()
@@ -335,7 +337,7 @@ function Download({
335337
usfmFileNames[bookCode]
336338
}`
337339
try {
338-
const response = await axios.get(newUrl)
340+
const response = await gitDoorAxios.get(newUrl)
339341
return response.data
340342
} catch (error) {
341343
console.error('Error fetching original USFM:', error)
@@ -356,7 +358,7 @@ function Download({
356358
acc[chapter] = 0
357359
return acc
358360
}, {})
359-
const methods = await axios.get('/api/methods')
361+
const methods = await gitDoorAxios.get('/api/methods')
360362
const method = methods.data.find((method) => method.title === project.method)
361363
if (!method?.offline_steps) {
362364
return null
@@ -384,7 +386,7 @@ function Download({
384386
const url = resourcesUrls[resource]
385387
try {
386388
if (resource === 'obs') {
387-
const response = await axios.get(url, { responseType: 'arraybuffer' })
389+
const response = await gitDoorAxios.get(url, { responseType: 'arraybuffer' })
388390
if (response.status !== 200)
389391
throw new Error(`Failed to fetch OBS archive: ${url}`)
390392

lib/axios.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import axios from 'axios'
2+
3+
const instance = axios.create()
4+
5+
instance.interceptors.request.use((config) => {
6+
const token = process.env.GIT_DOOR43_BEARER_TOKEN
7+
8+
if (token) {
9+
config.headers.Authorization = `Bearer ${token}`
10+
}
11+
12+
return config
13+
})
14+
15+
export default instance

pages/api/git/bible.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import axios from 'axios'
21
import usfm from 'usfm-js'
32

3+
import axios from '../../../lib/axios'
4+
45
import { parseChapter } from 'utils/usfmHelper'
56

67
/**

pages/api/git/info.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import axios from 'axios'
2-
31
import { tsvToJson } from '@texttree/translation-words-helpers'
42

3+
import axios from '../../../lib/axios'
4+
55
/**
66
* @swagger
77
* /api/git/info:

pages/api/git/obs-tn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import axios from 'axios'
2-
31
import { tsvToJson } from '@texttree/translation-words-helpers'
42

3+
import axios from '../../../lib/axios'
4+
55
import { filterNotes } from 'utils/helper'
66

77
/**

pages/api/git/obs-tq.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import axios from 'axios'
2-
31
import { tsvToJson } from '@texttree/translation-words-helpers'
42

3+
import axios from '../../../lib/axios'
4+
55
/**
66
* @swagger
77
* /api/git/obs-tq:

pages/api/git/obs-twl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import axios from 'axios'
2-
31
import { markRepeatedWords, tsvToJson } from '@texttree/translation-words-helpers'
42

3+
import axios from '../../../lib/axios'
4+
55
/**
66
* @swagger
77
* /api/git/obs-twl:

pages/api/git/obs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import axios from 'axios'
1+
import axios from '../../../lib/axios'
22

33
import { mdToJson } from 'utils/helper'
44

0 commit comments

Comments
 (0)