Port find.services to new logger

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-09-27 20:35:39 +01:00
parent 9334da889b
commit 6721d47f02

View File

@ -1,16 +1,17 @@
// Parse and return a find request
const log = require("../utils/logs.utils"); // Log Helper
const db = require("../services/dbAccess.services");
const san = require("../utils/sanitizer.utils");
import { logger } from "../utils/logger.utils";
// DB Query: query(collection, query)
// Define collection as all queries are for the "corpus" collection.
const col = "corpus";
async function name(id) {
log.out(`findServices.name: Finding station name: ${id}`, "info");
logger.debug(`findServices.name: Finding station name: ${id}`);
var name = san.cleanApiEndpointTxt(id.toUpperCase());
let query = { NLCDESC: name };
//var data = await db.query(col,query)
@ -18,7 +19,7 @@ async function name(id) {
}
async function crs(id) {
log.out(`findServices.crs: Finding crs: ${id}`, "info");
logger.debug(`findServices.crs: Finding crs: ${id}`);
var crs = san.cleanApiEndpointTxt(id.toUpperCase());
let query = { "3ALPHA": crs };
//var data = await db.query(col,query)
@ -26,16 +27,16 @@ async function crs(id) {
}
async function nlc(id) {
log.out(`findServices.nlc: Finding nlc: ${id}`, "info");
logger.debug(`findServices.nlc: Finding nlc: ${id}`);
var nlc = san.cleanApiEndpointNum(id);
let query = { NLC: parseInt(nlc) };
log.out(`findServices.nlc: NLC Converted to int: ${query}`, "info");
logger.trace(`findServices.nlc: NLC Converted to int: ${query}`);
//var data = await db.query(col,query)
return await db.query(col, query);
}
async function tiploc(id) {
log.out(`findServices.tiploc: Finding tiploc: ${id}`, "info");
logger.debug(`findServices.tiploc: Finding tiploc: ${id}`);
var tiploc = san.cleanApiEndpointTxt(id.toUpperCase());
let query = { TIPLOC: tiploc };
//var data = await db.query(col,query)
@ -43,7 +44,7 @@ async function tiploc(id) {
}
async function stanox(id) {
log.out(`findServices.stanox: Finding stanox: ${id}`, "info");
logger.debug(`findServices.stanox: Finding stanox: ${id}`);
var stanox = san.cleanApiEndpointNum(id);
let query = { STANOX: String(stanox) };
//var data = await db.query(col,query)