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 14 deletions
Showing only changes of commit 2df7c4b068 - Show all commits

View File

@ -1,7 +1,10 @@
// Parse and return a find request
import { query } from "../services/dbAccess.services";
import { cleanApiEndpointTxt, cleanApiEndpointNum } from "../utils/sanitizer.utils";
import {
cleanApiEndpointTxt,
cleanApiEndpointNum,
} from "../utils/sanitizer.utils";
import { logger } from "../utils/logger.utils";
// Define collection as all queries are for the "corpus" collection.

View File

@ -37,7 +37,9 @@ async function sendToGitea(body) {
logger.debug("issueService.sendToGitea: Issue created");
return { status: res.status, message: "issue created" };
} else {
logger.error(`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`);
logger.error(
`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`
);
return { status: res.status, message: "issue not created" };
}
} catch (err) {

View File

@ -65,7 +65,9 @@ function transformNrcc(input: any): NrccMessage[] | undefined {
}
function transformTrainServices(input: any): TrainServices[] {
logger.trace("utils/translators/ldb/staffLdb.transformTrainServices: Running");
logger.trace(
"utils/translators/ldb/staffLdb.transformTrainServices: Running"
);
let services: any = input?.service;
let output: TrainServices[] = [];
if (services === undefined) {
@ -150,7 +152,9 @@ export function calculateLength(input: any): number | undefined {
}
function transformUnspecifiedDateTime(input: string): Date | undefined {
logger.trace("utils/translators/ldb/staffStation.transformUnspecifiedDateTime: Running");
logger.trace(
"utils/translators/ldb/staffStation.transformUnspecifiedDateTime: Running"
);
if (!input) {
return undefined;
}

View File

@ -41,18 +41,22 @@ describe("Remove non-Alpha", () => {
const desired = outputs[key];
test(`Should return with only letters: ${key}`, () => {
expect(removeNonAlpha(input)).toEqual(desired);
})
});
}
})
});
describe("Remove non-alphanumeric", () => {
const inputs = ["DROP/*comment*/sampletable", "10; DROP TABLE members /*", "1F44"];
const inputs = [
"DROP/*comment*/sampletable",
"10; DROP TABLE members /*",
"1F44",
];
const outputs = ["DROPcommentsampletable", "10DROPTABLEmembers", "1F44"];
for (const key in inputs) {
const input = inputs[key];
const desired = outputs[key];
test(`Should return with only alphanumeric: ${key}`, () => {
expect(removeNonAlphanumeric(input)).toEqual(desired);
})
});
}
})
});