56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
// Parse and return a find request
|
|
|
|
import { query } from "../services/dbAccess.services";
|
|
import {
|
|
cleanApiEndpointTxt,
|
|
cleanApiEndpointNum,
|
|
} from "../utils/sanitizer.utils";
|
|
import { logger } from "../utils/logger.utils";
|
|
|
|
// Define collection as all queries are for the "corpus" collection.
|
|
const col: string = "corpus";
|
|
|
|
async function name(id: string) {
|
|
logger.debug(`findServices.name: Finding station name: ${id}`);
|
|
var name = cleanApiEndpointTxt(id.toUpperCase());
|
|
let queryObj = { NLCDESC: name };
|
|
return await query(col, queryObj);
|
|
}
|
|
|
|
async function crs(id: string) {
|
|
logger.debug(`findServices.crs: Finding crs: ${id}`);
|
|
var crs = cleanApiEndpointTxt(id.toUpperCase());
|
|
let queryObj = { "3ALPHA": crs };
|
|
return await query(col, queryObj);
|
|
}
|
|
|
|
async function nlc(id: string) {
|
|
logger.debug(`findServices.nlc: Finding nlc: ${id}`);
|
|
var nlc = cleanApiEndpointNum(id);
|
|
let queryObj = { NLC: parseInt(nlc) };
|
|
logger.trace(`findServices.nlc: NLC Converted to int: ${query}`);
|
|
return await query(col, queryObj);
|
|
}
|
|
|
|
async function tiploc(id: string) {
|
|
logger.debug(`findServices.tiploc: Finding tiploc: ${id}`);
|
|
var tiploc = cleanApiEndpointTxt(id.toUpperCase());
|
|
let queryObj = { TIPLOC: tiploc };
|
|
return await query(col, queryObj);
|
|
}
|
|
|
|
async function stanox(id: string) {
|
|
logger.debug(`findServices.stanox: Finding stanox: ${id}`);
|
|
var stanox = cleanApiEndpointNum(id);
|
|
let queryObj = { STANOX: String(stanox) };
|
|
return await query(col, queryObj);
|
|
}
|
|
|
|
module.exports = {
|
|
name,
|
|
crs,
|
|
nlc,
|
|
tiploc,
|
|
stanox,
|
|
};
|