Partial implementation of ldb.services

This commit is contained in:
Fred Boniface 2022-12-08 20:35:06 +00:00
parent b9ce8566bb
commit a09f5feefc
2 changed files with 44 additions and 8 deletions

View File

@ -1,11 +1,49 @@
const ldb = require('ldbs-json'); // Parse and return an LDB Request
const keys = require('/srv/keys/owlboard/keys.configs');
async function returnBoard(){ // FUNCTIONS
new ldb(keys.ldb,false); // 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 = { module.exports = {
returnBoard convertTiploc,
findBoard
} }

View File

@ -1,7 +1,5 @@
// Get CORPUS data from Network Rail and format the data for OwlBoard // 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 // FUNCTIONS
// get() : Exported: Returns: Ready Status and Owlboard Version // get() : Exported: Returns: Ready Status and Owlboard Version
// post() : Exported: Will check the API authentication and return status // post() : Exported: Will check the API authentication and return status