Backend: Begin issue API

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-01-30 21:18:21 +00:00
parent f6a6beb61a
commit b21ac8d562
3 changed files with 24 additions and 2 deletions

View File

@ -83,6 +83,7 @@ The app is designed to be run within Kubernetes or within a Docker container, as
|OWL_LDB_CORPUSUSER||YES|Network Rail CORPUS API Username| |OWL_LDB_CORPUSUSER||YES|Network Rail CORPUS API Username|
|OWL_LDB_CORPUSPASS||YES|Network Rail CORPUS API Password| |OWL_LDB_CORPUSPASS||YES|Network Rail CORPUS API Password|
|OWL_GIT_ISSUEBOT||NO|Gitea API Key for issue reporting| |OWL_GIT_ISSUEBOT||NO|Gitea API Key for issue reporting|
|OWL_GIT_APIENDPOINT||NO|Gitea API Endpoint|
In the case that OWL_LDB_SVKEY is not available, staff versions of departure board, etc. will not be available. In the case that OWL_LDB_SVKEY is not available, staff versions of departure board, etc. will not be available.

View File

@ -9,7 +9,7 @@
// extract() : Extract the CORPUS JSON file from the GZIP file. // extract() : Extract the CORPUS JSON file from the GZIP file.
// clean() : Cleans the CORPUS data, removing unneccesary non-stations from the data. // clean() : Cleans the CORPUS data, removing unneccesary non-stations from the data.
const log = require('../utils/log.utils'); // Log Helper const log = require('../utils/log.utils'); // Log Helper
const axios = require('axios') const axios = require('axios')
const gz = require('node-gzip') const gz = require('node-gzip')
@ -22,7 +22,7 @@ async function subset(allCorpus) {
return cleanCorpus return cleanCorpus
} }
async function get(){ async function get() {
var gzipData = await fetch() var gzipData = await fetch()
var allCorpus = await extract(gzipData) var allCorpus = await extract(gzipData)
return allCorpus return allCorpus

View File

@ -0,0 +1,21 @@
const axios = require('axios')
async function sendToGitea(body) {
let key = process.env.OWL_GIT_ISSUEBOT
let url = process.env.OWL_GIT_APIENDPOINT
let options = {
method: 'post',
timeout: 2000,
headers: {
Accept: 'application/json',
Authorization: key
},
data: body
}
await axios.post(url, options)
}
module.exports = {
sendToGitea
}