From 4b69dc3af59cb16b334b5765194ed633e890a848 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 5 Feb 2024 21:25:44 +0000 Subject: [PATCH] - Ensure headcodes and trainUIDs can be accepted in lower case. - Remove testing endpoints - Add deprecation notices to APIv1 functions Signed-off-by: Fred Boniface --- app.js | 2 -- src/controllers/pis.controllers.js | 6 ------ src/controllers/train.controllers.js | 4 ++++ src/routes/pis.routes.ts | 1 - src/services/trainService.services.ts | 4 ++-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 9798d8c..431483d 100644 --- a/app.js +++ b/app.js @@ -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"; diff --git a/src/controllers/pis.controllers.js b/src/controllers/pis.controllers.js index f83970b..bdc1e65 100644 --- a/src/controllers/pis.controllers.js +++ b/src/controllers/pis.controllers.js @@ -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, }; diff --git a/src/controllers/train.controllers.js b/src/controllers/train.controllers.js index dcf6b0e..986b59f 100644 --- a/src/controllers/train.controllers.js +++ b/src/controllers/train.controllers.js @@ -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; diff --git a/src/routes/pis.routes.ts b/src/routes/pis.routes.ts index 6e2fc63..6a9aee8 100644 --- a/src/routes/pis.routes.ts +++ b/src/routes/pis.routes.ts @@ -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; diff --git a/src/services/trainService.services.ts b/src/services/trainService.services.ts index 8baefdc..f013651 100644 --- a/src/services/trainService.services.ts +++ b/src/services/trainService.services.ts @@ -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)] },