// 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` const keys = require('/srv/keys/owlboard/keys.configs'); const axios = require('axios'); const zlib = require('zlib'); const fs = require('fs'); async function initCorpus(){ // EXPORT - Uses getCorpus() to download the CORPUS GZIP and then processes it. let gzipData = await getCorpus(); console.log(gzipData); } 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(){ // Clean the CORPUS as per the temporary Python Script } module.exports = { initCorpus }