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');
|
const keys = require('/srv/keys/owlboard/keys.configs');
|
||||||
|
|
||||||
async function returnBoard(){
|
async function returnBoard(){
|
||||||
new ldb(keys.ldb,false)
|
new ldb(keys.ldb,false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -5,24 +5,26 @@
|
|||||||
const keys = require('/srv/keys/owlboard/keys.configs');
|
const keys = require('/srv/keys/owlboard/keys.configs');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
async function getCorpus(){
|
async function initCorpus(){ // EXPORT - Uses getCorpus() to download the CORPUS GZIP and then processes it.
|
||||||
authHead = Buffer.from(`${keys.nr_user}:${keys.nr_pass}`).toString('base64');
|
let gzipData = await getCorpus();
|
||||||
getOpts = {
|
console.log(gzipData);
|
||||||
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 decompress(data){
|
async function getCorpus(){ // Download and return the GZIP file as an arraybuffer.
|
||||||
let raw = zlib.gunzip(data);
|
authHead = Buffer.from(`${keys.nr_user}:${keys.nr_pass}`).toString('base64');
|
||||||
return raw;
|
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(){
|
async function cleanCorpus(){
|
||||||
@ -30,5 +32,5 @@ async function cleanCorpus(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCorpus
|
initCorpus
|
||||||
}
|
}
|
Reference in New Issue
Block a user