diff --git a/src/services/ldb.services.js b/src/services/ldb.services.js index 7b0fba5..1b09285 100644 --- a/src/services/ldb.services.js +++ b/src/services/ldb.services.js @@ -1,11 +1,49 @@ -const ldb = require('ldbs-json'); -const keys = require('/srv/keys/owlboard/keys.configs'); +// Parse and return an LDB Request -async function returnBoard(){ - new ldb(keys.ldb,false); - +// FUNCTIONS +// returnBoard(staff, ) : [staff: BOOL, whether to use the staff or public API] +// post() : Exported: Will check the API authentication and return status + +const ldb = require('ldbs-json') +const keys = require('/srv/keys/owlboard/keys.configs') + +async function findBoard(input, staff){ + // Check whether input is CRS or TIPLOC + // if TIPLOC then convert to CRS + // then call the correct function and + // return that output to calling function + // for now, just call arrDepBoard(CRS) + var output = await arrDepBoard(input) + return output +} + +async function arrDepBoard(CRS){ + var valid = await checkCrs(CRS) + if (valid != false){ + var options = { + numRows: 10, + crs: CRS.toUpperCase() + } + var api = new ldb(keys.ldb,false) + var reply = await api.call("GetArrDepBoardWithDetails",options) + return reply + } else if (valid == false) { + return {status: false, reason: "Invalid CRS/3alpha code"}; + } }; +async function checkCrs(input){ + // Check whether CRS is valid + // Until implemented always return true + return true +} + +async function convertTiploc(TIPLOC){ + // Convert TIPLOC to CRS with DBLookup + return TIPLOC +} + module.exports = { - returnBoard + convertTiploc, + findBoard } \ No newline at end of file diff --git a/src/services/test.services.js b/src/services/test.services.js index a5932fd..e2573de 100644 --- a/src/services/test.services.js +++ b/src/services/test.services.js @@ -1,7 +1,5 @@ // 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` - // FUNCTIONS // get() : Exported: Returns: Ready Status and Owlboard Version // post() : Exported: Will check the API authentication and return status