TimetableAPI-Upgrade #64

Merged
fred.boniface merged 36 commits from TimetableAPI-Upgrade into main 2024-02-11 15:53:17 +00:00
5 changed files with 6 additions and 11 deletions
Showing only changes of commit 4b69dc3af5 - Show all commits

2
app.js
View File

@ -20,14 +20,12 @@ const authenticate = require("./src/middlewares/auth.middlewares");
// Internal Requires // Internal Requires
const version = require("./src/configs/version.configs"); 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 pis2Rtr = require("./src/routes/pis.routes"); // API Version 2 Routes
const ref2Rtr = require("./src/routes/ref.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 live2Rtr = require("./src/routes/live.routes"); // API Version 2 Routes
const tt2Rtr = require("./src/routes/timetable.routes"); // API Version 2 const tt2Rtr = require("./src/routes/timetable.routes"); // API Version 2
const user2Rtr = require("./src/routes/user.routes"); // API Version 2 Routes const user2Rtr = require("./src/routes/user.routes"); // API Version 2 Routes
const miscRtr = require("./src/routes/misc.routes"); // Non-Public API Routes const miscRtr = require("./src/routes/misc.routes"); // Non-Public API Routes
const testRtr = require("./src/routes/test.routes");
// Set Server Configurations // Set Server Configurations
const srvListen = process.env.OWL_SRV_LISTEN || "0.0.0.0"; 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 = { module.exports = {
byStartEndCRS, byStartEndCRS,
byCode, byCode,
random, random,
testingTiplocArray,
}; };

View File

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

View File

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

View File

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