This repository has been archived on 2023-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
OwlBoard/src/services/ldb.services.js

49 lines
1.3 KiB
JavaScript

// Parse and return an LDB Request
// 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 = {
convertTiploc,
findBoard
}