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