Remove unused code from controllers

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-10-12 21:06:30 +01:00
parent 9e6706d109
commit 9674ad9392
7 changed files with 0 additions and 221 deletions

View File

@ -1,58 +0,0 @@
const find = require("../services/find.services");
async function findName(req, res, next) {
try {
var id = req.params.id;
res.json(await find.name(id));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
async function findCrs(req, res, next) {
try {
var id = req.params.id;
res.json(await find.crs(id));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
async function findNlc(req, res, next) {
try {
var id = req.params.id;
res.json(await find.nlc(id));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
async function findTiploc(req, res, next) {
try {
var id = req.params.id;
res.json(await find.tiploc(id));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
async function findStanox(req, res, next) {
try {
var id = req.params.id;
res.json(await find.stanox(id));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
module.exports = {
findName,
findCrs,
findNlc,
findTiploc,
findStanox,
};

View File

@ -1,35 +0,0 @@
const kube = require("../services/kube.services");
async function getAlive(req, res, next) {
try {
var state = kube.getAlive();
res.status((await state).code).send((await state).state);
} catch (err) {
res.status("503").send({ state: "error" });
}
}
async function getReady(req, res, next) {
try {
res.json(await kube.getReady(req.body));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
async function getTime(req, res, next) {
try {
res.json(await kube.getTime(req.body));
} catch (err) {
console.error("Unknown Error", err.message);
err.status = 503;
next(err);
}
}
module.exports = {
getAlive,
getReady,
getTime,
};

View File

@ -1,17 +1,5 @@
const ldb = require("../services/ldb.services");
async function get(req, res, next) {
// API v1 only
try {
var id = req.params.id;
res.json(await ldb.get(id));
} catch (err) {
console.error("Unknown Error", err.message);
err.status = 500;
next(err);
}
}
async function getTrain(req, res, next) {
// API v2 Only
if (!req.isAuthed) {
@ -66,7 +54,6 @@ async function getStation(req, res, next) {
}
module.exports = {
get,
getTrain,
getStation,
};

View File

@ -1,51 +0,0 @@
const ldb = require("../services/ldb.services");
async function get(req, res, next) {
try {
var id = req.params.id;
res.json(await ldb.get(id, true));
} catch (err) {
console.error("Unknown Error", err.message);
err.status = 500;
next(err);
}
}
async function getReasonCodeList(req, res, next) {
try {
res.json(await ldb.getReasonCodeList());
} catch (err) {
console.error("ERROR", err.message);
err.status = 500;
next(err);
}
}
async function getReasonCode(req, res, next) {
try {
const code = req.params.code;
res.json(await ldb.getReasonCode(code));
} catch (err) {
console.error("ERROR", err.message);
err.status = 500;
next(err);
}
}
async function getTrainByRID(req, res, next) {
try {
const rid = req.params.rid;
res.json(await ldb.getServiceByRID(rid));
} catch (err) {
console.error("ERROR", err);
err.status = 500;
next(err);
}
}
module.exports = {
get,
getReasonCodeList,
getReasonCode,
getTrainByRID,
};

View File

@ -1,37 +0,0 @@
const list = require("../services/list.services");
async function getStations(req, res, next) {
try {
res.json(await list.getStations(req.body));
} catch (err) {
console.error("Controller Error", err.message);
err.status = 500;
next(err);
}
}
async function getCorpus(req, res, next) {
try {
res.json(await list.getCorpus(req.body));
} catch (err) {
console.error("Controller Error", err.message);
err.status = 500;
next(err);
}
}
async function hits(req, res, next) {
try {
res.json(await list.hits());
} catch (err) {
console.error("Controller Error", err);
err.status = 500;
next(err);
}
}
module.exports = {
getStations,
getCorpus,
hits,
};

View File

@ -1,21 +1,5 @@
const pis = require("../services/pis.services");
async function byOrigDest(req, res, next) {
if (!req.isAuthed) {
const err = new Error("Unauthorized");
err.status = 401;
throw err;
}
try {
let start = req.params.start;
let end = req.params.end;
res.json(await pis.findPisByOrigDest(start, end));
} catch (err) {
console.error("Unknown Error", err.message);
next(err);
}
}
/* Used in /api/v2 */
async function byStartEndCRS(req, res, next) {
if (!req.isAuthed) {

View File

@ -1,16 +1,5 @@
const stat = require("../services/stats.services");
async function get(req, res, next) {
// API V1
try {
res.json(await stat.hits());
} catch (err) {
console.error("Controller Error", err);
err.status = 500;
next(err);
}
}
async function versions(req, res, next) {
// API v2
try {