pis #12

Merged
fred.boniface merged 95 commits from pis into main 2023-05-06 21:54:51 +01:00
4 changed files with 37 additions and 7 deletions
Showing only changes of commit f1c616e9e0 - Show all commits

View File

@ -3,7 +3,7 @@ const ldb = require('../services/ldb.services');
async function get(req, res, next){
try {
var id = req.params.id
res.json(await ldb.get(req.body, id))
res.json(await ldb.get(id))
} catch (err) {
console.error(`Unknown Error`, err.message);
err.status = 500

View File

@ -0,0 +1,16 @@
const ldb = require('../services/ldb.services');
async function get(req, res, next){
try {
var id = req.params.id
res.json(await ldb.get(id, true))
} catch (err) {
console.error(`Unknown Error`, err.message);
err.status = 500
next(err);
}
}
module.exports = {
get
}

View File

@ -1,6 +1,6 @@
const express = require('express');
const router = express.Router();
const ldbController = require('../controllers/ldb.controllers');
const ldbsController = require('../controllers/ldbs.controllers');
/* GET programming languages. */
//router.get('/', programmingLanguagesController.get);
@ -14,6 +14,6 @@ const ldbController = require('../controllers/ldb.controllers');
/* DELETE programming language */
//router.delete('/:id', programmingLanguagesController.remove);
router.get('/:id', ldbController.get);
router.get('/:id', ldbsController.get);
module.exports = router;

View File

@ -9,7 +9,7 @@ const db = require('../services/dbAccess.services')
const ldbKey = process.env.OWL_LDB_KEY
const ldbsvKey = process.env.OWL_LDB_SVKEY
async function get(body, id){
async function get(id, staff=false){
var cleanId = san.cleanApiEndpointTxt(id);
var obj = await util.checkCrs(cleanId);
try {
@ -33,13 +33,27 @@ async function arrDepBoard(CRS){
crs: CRS.toUpperCase()
}
var api = new ldb(ldbKey,false)
var reply = api.call("GetArrDepBoardWithDetails", options, false, false)
return await reply
return await api.call("GetArrDepBoardWithDetails", options, false, false)
} catch (err) {
log.out(`ldbService.arrDepBoard: Lookup Failed for: ${CRS}`, "warn")
return {GetStationBoardResult: "not available", Reason: `The CRS code ${CRS} is not valid`, Why: `Sometimes a station will have more than one CRS - for example Filton Abbey Wood has FIT and FAW however schedules are only available when looking up with FIT - this is how the National Rail Enquiries systems work.`};
}
};
}
async function arrDepBoardStaff(CRS) {
log.out(`ldbService.arrDepBoardStaff: Trying to fetch ArrDep Board for ${CRS}`, "dbug")
try {
const options = {
numRows: 25,
crs: CRS.toUpperCase()
}
const api = new ldb(ldbsvKey,true)
return await api.call("Unknown") // Need to find out the syntax of this!
} catch (err) {
log.out(`ldbService.arrDepBoardStaff: Lookup Failed for: ${CRS}, "warn`)
return {GetStationBoardResult: "not available", Reason: `The CRS code ${CRS} is not valid`, Why: `Sometimes a station will have more than one CRS - for example Filton Abbey Wood has FIT and FAW however schedules are only available when looking up with FIT - this is how the National Rail Enquiries systems work.`};
}
}
module.exports = {
get