2022-12-06 01:20:43 +00:00
|
|
|
// Get CORPUS data from Network Rail and format the data for OwlBoard
|
|
|
|
|
|
|
|
// Username and password must be stored in `/srv/keys/owlboard/keys.config.js`
|
|
|
|
|
2022-12-06 13:40:03 +00:00
|
|
|
const keys = require('/srv/keys/owlboard/keys.configs');
|
|
|
|
const axios = require('axios');
|
2022-12-07 01:28:00 +00:00
|
|
|
const zlib = require('zlib');
|
2022-12-06 13:40:03 +00:00
|
|
|
|
2022-12-07 01:28:00 +00:00
|
|
|
async function getCorpus(){
|
2022-12-06 13:40:03 +00:00
|
|
|
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) => {
|
2022-12-07 01:28:00 +00:00
|
|
|
decompress(response);
|
|
|
|
console.log(raw);
|
2022-12-06 13:40:03 +00:00
|
|
|
})
|
2022-12-06 01:20:43 +00:00
|
|
|
}
|
|
|
|
|
2022-12-07 01:28:00 +00:00
|
|
|
async function decompress(data){
|
|
|
|
let raw = zlib.gunzip(data);
|
|
|
|
return raw;
|
2022-12-06 13:40:03 +00:00
|
|
|
}
|
2022-12-06 01:20:43 +00:00
|
|
|
|
|
|
|
async function cleanCorpus(){
|
2022-12-06 13:40:03 +00:00
|
|
|
// Clean the CORPUS as per the temporary Python Script
|
2022-12-06 01:20:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getCorpus
|
|
|
|
}
|