CORPUS data is now stored in arraybuffer
This commit is contained in:
parent
1bdd18eb21
commit
7eac21411a
@ -2,7 +2,8 @@ const ldb = require('ldbs-json');
|
||||
const keys = require('/srv/keys/owlboard/keys.configs');
|
||||
|
||||
async function returnBoard(){
|
||||
new ldb(keys.ldb,false)
|
||||
new ldb(keys.ldb,false);
|
||||
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -5,24 +5,26 @@
|
||||
const keys = require('/srv/keys/owlboard/keys.configs');
|
||||
const axios = require('axios');
|
||||
const zlib = require('zlib');
|
||||
const fs = require('fs');
|
||||
|
||||
async function getCorpus(){
|
||||
authHead = Buffer.from(`${keys.nr_user}:${keys.nr_pass}`).toString('base64');
|
||||
getOpts = {
|
||||
method: 'get',
|
||||
url: 'https://datafeeds.networkrail.co.uk/ntrod/SupportingFileAuthenticate?type=CORPUS',
|
||||
timeour: 3000,
|
||||
headers: {'Authorization': `Basic ${authHead}`}
|
||||
}
|
||||
axios(getOpts).then((response) => {
|
||||
decompress(response);
|
||||
console.log(raw);
|
||||
})
|
||||
async function initCorpus(){ // EXPORT - Uses getCorpus() to download the CORPUS GZIP and then processes it.
|
||||
let gzipData = await getCorpus();
|
||||
console.log(gzipData);
|
||||
}
|
||||
|
||||
async function decompress(data){
|
||||
let raw = zlib.gunzip(data);
|
||||
return raw;
|
||||
async function getCorpus(){ // Download and return the GZIP file as an arraybuffer.
|
||||
authHead = Buffer.from(`${keys.nr_user}:${keys.nr_pass}`).toString('base64');
|
||||
const getReq = axios.create({
|
||||
method: 'get',
|
||||
baseURL: 'https://datafeeds.networkrail.co.uk/ntrod/SupportingFileAuthenticate?type=CORPUS',
|
||||
timeout: 3000,
|
||||
headers: {'Authorization': `Basic ${authHead}`},
|
||||
responseType: 'arraybuffer'
|
||||
});
|
||||
let download = await getReq().then(function (response){
|
||||
return response.data;
|
||||
})
|
||||
return download;
|
||||
}
|
||||
|
||||
async function cleanCorpus(){
|
||||
@ -30,5 +32,5 @@ async function cleanCorpus(){
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCorpus
|
||||
initCorpus
|
||||
}
|
Reference in New Issue
Block a user