- Ensure headcodes and trainUIDs can be accepted in lower case.

- Remove testing endpoints
 - Add deprecation notices to APIv1 functions

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2024-02-05 21:25:44 +00:00
parent 47056d2dae
commit 4b69dc3af5
5 changed files with 6 additions and 11 deletions

2
app.js
View File

@ -20,14 +20,12 @@ const authenticate = require("./src/middlewares/auth.middlewares");
// Internal Requires
const version = require("./src/configs/version.configs");
//const trainRtr = require("./src/routes/train.routes");
const pis2Rtr = require("./src/routes/pis.routes"); // API Version 2 Routes
const ref2Rtr = require("./src/routes/ref.routes"); // API Version 2 Routes
const live2Rtr = require("./src/routes/live.routes"); // API Version 2 Routes
const tt2Rtr = require("./src/routes/timetable.routes"); // API Version 2
const user2Rtr = require("./src/routes/user.routes"); // API Version 2 Routes
const miscRtr = require("./src/routes/misc.routes"); // Non-Public API Routes
const testRtr = require("./src/routes/test.routes");
// Set Server Configurations
const srvListen = process.env.OWL_SRV_LISTEN || "0.0.0.0";

View File

@ -47,14 +47,8 @@ async function random(req, res, next) {
}
}
async function testingTiplocArray(req, res, next) {
let array = JSON.parse(req.params.array);
res.json(await pis.findByTiplocArray(array));
}
module.exports = {
byStartEndCRS,
byCode,
random,
testingTiplocArray,
};

View File

@ -1,6 +1,10 @@
import { logger } from "../utils/logger.utils";
const train = require("../services/trainService.services");
async function getByHeadcodeToday(req, res, next) {
// Deprecated - for future removal.
logger.warn("Deprecated Function Called - trainService.services-getByHeadcodeToday")
if (!req.isAuthed) {
const err = new Error("Unauthorized");
err.status = 401;

View File

@ -5,6 +5,5 @@ const pisCtr = require("../controllers/pis.controllers");
// PIS
router.get("/byCode/:code", pisCtr.byCode);
router.get("/byStartEnd/:startCrs/:endCrs", pisCtr.byStartEndCRS);
router.get("/test/bytiplocarray/:array", pisCtr.testingTiplocArray);
module.exports = router;

View File

@ -33,7 +33,7 @@ export async function findByHeadcode(
const shortDay = getShortDay(searchDate);
const query = {
headcode: sanitizedHeadcode,
headcode: sanitizedHeadcode.toUpperCase(),
scheduleStartDate: { $lte: searchDate },
scheduleEndDate: { $gte: searchDate },
daysRun: { $in: [shortDay] },
@ -64,7 +64,7 @@ export async function findByTrainUid(
// Build query
const query = {
trainUid: uid,
trainUid: uid.toUpperCase(),
scheduleStartDate: { $lte: queryDate },
scheduleEndDate: { $gte: queryDate },
daysRun: { $in: [getShortDay(queryDate)] },