2023-02-09 20:34:53 +00:00
|
|
|
// Parse and return a find request
|
|
|
|
|
|
|
|
const log = require('../utils/log.utils'); // Log Helper
|
|
|
|
const db = require('../services/dbAccess.services');
|
2023-05-06 21:54:49 +01:00
|
|
|
const san = require('../utils/sanitizer.utils');
|
2023-02-09 20:34:53 +00:00
|
|
|
|
|
|
|
// DB Query: query(collection, query)
|
|
|
|
|
|
|
|
// Define collection as all queries are for the "corpus" collection.
|
2023-05-06 21:54:49 +01:00
|
|
|
const col = 'corpus';
|
2023-02-09 20:34:53 +00:00
|
|
|
|
|
|
|
async function name(id){
|
2023-05-06 21:54:49 +01:00
|
|
|
log.out(`findServices.name: Finding station name: ${id}`, 'info');
|
|
|
|
var name = san.cleanApiEndpointTxt(id.toUpperCase());
|
|
|
|
let query = {NLCDESC: name};
|
|
|
|
//var data = await db.query(col,query)
|
|
|
|
return await db.query(col,query);
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function crs(id){
|
2023-05-06 21:54:49 +01:00
|
|
|
log.out(`findServices.crs: Finding crs: ${id}`, 'info');
|
|
|
|
var crs = san.cleanApiEndpointTxt(id.toUpperCase());
|
|
|
|
let query = {'3ALPHA': crs};
|
|
|
|
//var data = await db.query(col,query)
|
|
|
|
return await db.query(col,query);
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function nlc(id){
|
2023-05-06 21:54:49 +01:00
|
|
|
log.out(`findServices.nlc: Finding nlc: ${id}`, 'info');
|
|
|
|
var nlc = san.cleanApiEndpointNum(id);
|
|
|
|
let query = {NLC: parseInt(nlc)};
|
|
|
|
log.out(`findServices.nlc: NLC Converted to int: ${query}`, 'info');
|
|
|
|
//var data = await db.query(col,query)
|
|
|
|
return await db.query(col,query);
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function tiploc(id){
|
2023-05-06 21:54:49 +01:00
|
|
|
log.out(`findServices.tiploc: Finding tiploc: ${id}`, 'info');
|
|
|
|
var tiploc = san.cleanApiEndpointTxt(id.toUpperCase());
|
|
|
|
let query = {TIPLOC: tiploc};
|
|
|
|
//var data = await db.query(col,query)
|
|
|
|
return await db.query(col,query);
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function stanox(id){
|
2023-05-06 21:54:49 +01:00
|
|
|
log.out(`findServices.stanox: Finding stanox: ${id}`, 'info');
|
|
|
|
var stanox = san.cleanApiEndpointNum(id);
|
|
|
|
let query = {STANOX: String(stanox)};
|
|
|
|
//var data = await db.query(col,query)
|
|
|
|
return await db.query(col,query);
|
2023-02-09 20:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2023-05-06 21:54:49 +01:00
|
|
|
name,
|
|
|
|
crs,
|
|
|
|
nlc,
|
|
|
|
tiploc,
|
|
|
|
stanox
|
|
|
|
};
|