Compare commits
No commits in common. "45fdf1904d3ef259485c1c54f1a47206e4298024" and "9674ad9392342eec8f268de8f795cdadfd0b2e7f" have entirely different histories.
45fdf1904d
...
9674ad9392
1
app.js
1
app.js
|
@ -72,6 +72,7 @@ app.use("/api/v2/timetable", tt2Rtr); // API Version 2
|
|||
app.use("/api/v2/user", user2Rtr); // API Version 2
|
||||
app.use("/misc", miscRtr); // Non public-api endpoints (Stats, Issue, etc.)
|
||||
|
||||
|
||||
app.use("/api/v1/auth/test", authenticate, (req, res) =>
|
||||
res.status(200).json({
|
||||
status: "ok",
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"zlib": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@owlboard/ts-types": "^0.1.0",
|
||||
"@owlboard/ts-types": "^0.0.9",
|
||||
"@types/jest": "^29.5.3",
|
||||
"eslint": "^8.39.0",
|
||||
"jest": "^29.6.2",
|
||||
|
@ -1983,9 +1983,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@owlboard/ts-types": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fts-types/-/0.1.0/ts-types-0.1.0.tgz",
|
||||
"integrity": "sha512-5dLkm1wEimiv+pr5wuJbJvPfSek9WuApl/4SBwoFXVO2bmAIktFIHi+bznXKnhW9a7nJwX/w+bVwwJpBOI3I1g==",
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fts-types/-/0.0.9/ts-types-0.0.9.tgz",
|
||||
"integrity": "sha512-kdystFqrfj6SF8jchv4OoaBIFfJF4YoM7m09POZfuEWrdj69IXZG41k0cfYadft1wZs8L6mcZIunu8t/S5Q82Q==",
|
||||
"dev": true,
|
||||
"license": "GPL-3.0-or-later"
|
||||
},
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
"scripts": {
|
||||
"build": "tsc",
|
||||
"run": "tsc && node dist/app.js",
|
||||
"dev": "NODE_ENV=development tsc && node dist/app.js",
|
||||
"start": "node app.js",
|
||||
"test": "jest",
|
||||
"format": "npx prettier -w ."
|
||||
|
|
|
@ -48,6 +48,7 @@ async function random(req, res, next) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
byOrigDest,
|
||||
byStartEndCRS,
|
||||
byCode,
|
||||
random,
|
||||
|
|
|
@ -23,6 +23,7 @@ async function statistics(req, res, next) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
get,
|
||||
versions,
|
||||
statistics,
|
||||
};
|
||||
|
|
|
@ -4,11 +4,6 @@ const logger = require("../utils/logger.utils");
|
|||
module.exports = async function authCheck(req, res, next) {
|
||||
//log.out("authMiddlewares: Checking authentication", "dbug");
|
||||
logger.logger.debug("Auth check starting");
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
logger.logger.warn("DEVELOPMENT MODE - AUTHENTICATION DISABLED")
|
||||
res.isAuthed = true;
|
||||
return next()
|
||||
}
|
||||
try {
|
||||
var uuid = req.headers.uuid;
|
||||
} catch (err) {
|
||||
|
|
|
@ -4,7 +4,6 @@ const db = require("../services/dbAccess.services");
|
|||
const clean = require("../utils/sanitizer.utils");
|
||||
|
||||
import { logger } from "../utils/logger.utils";
|
||||
import { queryAggregate } from "./dbAccess.services";
|
||||
|
||||
const supported = ["GW", "UK"];
|
||||
|
||||
|
@ -48,66 +47,19 @@ async function findByTiplocArray(tiplocArray: string[]) {
|
|||
};
|
||||
const res = await db.query("pis", query);
|
||||
// If res is empty then try to find partial match
|
||||
if (res.length) {
|
||||
/* if (res.length) {
|
||||
return res;
|
||||
} else {
|
||||
let partial = await findPartialMatchByTiploc(tiplocArray);
|
||||
return partial
|
||||
}
|
||||
} */
|
||||
return await res;
|
||||
}
|
||||
|
||||
async function findPartialMatchByTiploc(tiplocArray: string[]) {
|
||||
// Do some magic here, similar to findPisByOrigDest but
|
||||
// ensuring that the stops in the array match the last
|
||||
// x number of items in the array.
|
||||
|
||||
const pipeline = [
|
||||
{
|
||||
$addFields: {
|
||||
reversedStops: {
|
||||
$reverseArray: "$stops",
|
||||
},
|
||||
reversedQueryArray: {
|
||||
$reverseArray: tiplocArray,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$gt: [
|
||||
{
|
||||
$indexOfArray: [
|
||||
"$reversedStops",
|
||||
{
|
||||
$arrayElemAt: ["$reversedQueryArray", 0],
|
||||
}
|
||||
],
|
||||
},
|
||||
-1,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
code: 1,
|
||||
skipStops: {
|
||||
$subtract: [
|
||||
{
|
||||
$size: "$stops",
|
||||
},
|
||||
{
|
||||
$size: tiplocArray,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const res = await queryAggregate('pis', pipeline)
|
||||
console.log(JSON.stringify(res))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -111,10 +111,7 @@ function transformTrainServices(input: any): TrainServices[] {
|
|||
|
||||
function checkIsSupressed(service: TrainServices): string | undefined {
|
||||
logger.trace("utils/translators/ldb/staffStation.checkIsSupressed: Running");
|
||||
if (
|
||||
service.serviceIsSupressed === "true" ||
|
||||
service.isPassengerService === "false"
|
||||
) {
|
||||
if (service.serviceIsSupressed === "true" || service.isPassengerService === "false") {
|
||||
return "true";
|
||||
} else {
|
||||
return undefined;
|
||||
|
|
Loading…
Reference in New Issue