newStaffLDB-API #48

Merged
fred.boniface merged 85 commits from newStaffLDB-API into main 2023-10-03 21:35:03 +01:00
5 changed files with 27 additions and 6 deletions
Showing only changes of commit 0bb984999f - Show all commits

View File

@ -134,3 +134,15 @@ module.exports = {
delRegReq, delRegReq,
colCount, colCount,
}; };
export {
query,
queryProject,
queryAggregate,
increment,
addUser,
userAtime,
addRegReq,
delRegReq,
colCount,
};

View File

@ -3,7 +3,7 @@ const testing = require("../services/mail.services");
import { logger } from "../utils/logger.utils"; import { logger } from "../utils/logger.utils";
async function getAlive() { async function getAlive() {
logger.trace("kubeServices.getAlive: alive hook checked") logger.trace("kubeServices.getAlive: alive hook checked");
return { code: 200, state: { state: "alive", noise: "twit-twoo" } }; return { code: 200, state: { state: "alive", noise: "twit-twoo" } };
} }

View File

@ -8,7 +8,9 @@ import { logger } from "../utils/logger.utils";
const supported = ["GW", "UK"]; const supported = ["GW", "UK"];
async function findPisByOrigDest(start, end) { async function findPisByOrigDest(start, end) {
logger.debug(`pisServices.findPisByOrigDest: Searching for Orig: ${start}, Dest: ${end}`); logger.debug(
`pisServices.findPisByOrigDest: Searching for Orig: ${start}, Dest: ${end}`
);
const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase()); const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase());
const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase()); const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase());
const query = { const query = {

View File

@ -19,7 +19,10 @@ async function createRegKey(body) {
const message = await auth.generateConfirmationEmail(body.email, uuid); const message = await auth.generateConfirmationEmail(body.email, uuid);
if (!message) { if (!message) {
const err = new Error("Message generation error"); const err = new Error("Message generation error");
logger.error(err, 'registerServices.createRegKey: Error generating email'); logger.error(
err,
"registerServices.createRegKey: Error generating email"
);
return 500; return 500;
} }
if ((await mail.send(message)) == true) { if ((await mail.send(message)) == true) {
@ -37,7 +40,7 @@ async function regUser(req) {
// Add input validation // Add input validation
logger.trace(`Read UUID: ${req.uuid}`); logger.trace(`Read UUID: ${req.uuid}`);
const res = await auth.checkRequest(req.uuid); const res = await auth.checkRequest(req.uuid);
logger.debug(res, 'registrationServices'); logger.debug(res, "registrationServices");
if (res.result) { if (res.result) {
const uuid = await auth.generateKey(); const uuid = await auth.generateKey();
const apiKey = await db.addUser(uuid, res.domain); const apiKey = await db.addUser(uuid, res.domain);

View File

@ -6,7 +6,9 @@ import { logger } from "../utils/logger.utils";
async function findByHeadcodeToday(headcode) { async function findByHeadcodeToday(headcode) {
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase(); const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
logger.debug(`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`); logger.debug(
`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`
);
const now = new Date(); const now = new Date();
const dayMap = ["su", "m", "t", "w", "th", "f", "s"]; const dayMap = ["su", "m", "t", "w", "th", "f", "s"];
const shortDay = dayMap[now.getDay()]; // Fetch short day from map const shortDay = dayMap[now.getDay()]; // Fetch short day from map
@ -39,7 +41,9 @@ async function findByHeadcodeToday(headcode) {
async function findByHeadcode(date, headcode) { async function findByHeadcode(date, headcode) {
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase(); const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
logger.debug(`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`); logger.debug(
`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`
);
let searchDate; let searchDate;
if (date === "now") { if (date === "now") {
searchDate = new Date(); searchDate = new Date();