newStaffLDB-API #48
2
app.js
2
app.js
@ -19,7 +19,7 @@ const cors = require("cors");
|
|||||||
const authenticate = require("./src/middlewares/auth.middlewares");
|
const authenticate = require("./src/middlewares/auth.middlewares");
|
||||||
|
|
||||||
// Internal Requires
|
// Internal Requires
|
||||||
const version = require("./src/configs/version.configs");/*
|
const version = require("./src/configs/version.configs"); /*
|
||||||
const listRtr = require("./src/routes/list.routes");
|
const listRtr = require("./src/routes/list.routes");
|
||||||
const ldbRtr = require("./src/routes/ldb.routes");
|
const ldbRtr = require("./src/routes/ldb.routes");
|
||||||
const ldbsRtr = require("./src/routes/ldbs.routes");
|
const ldbsRtr = require("./src/routes/ldbs.routes");
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
// Parse and return a find request
|
// Parse and return a find request
|
||||||
|
|
||||||
import { query } from "../services/dbAccess.services";
|
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";
|
import { logger } from "../utils/logger.utils";
|
||||||
|
|
||||||
// Define collection as all queries are for the "corpus" collection.
|
// Define collection as all queries are for the "corpus" collection.
|
||||||
|
@ -35,14 +35,16 @@ async function sendToGitea(body) {
|
|||||||
|
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
logger.debug("issueService.sendToGitea: Issue created");
|
logger.debug("issueService.sendToGitea: Issue created");
|
||||||
return {status: res.status, message: "issue created"};
|
return { status: res.status, message: "issue created" };
|
||||||
} else {
|
} else {
|
||||||
logger.error(`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`);
|
logger.error(
|
||||||
return {status: res.status, message: "issue not created"};
|
`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`
|
||||||
|
);
|
||||||
|
return { status: res.status, message: "issue not created" };
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err, `issueService.sendToGitea`);
|
logger.error(err, `issueService.sendToGitea`);
|
||||||
return {status:500, message: "Internal Server Error"};
|
return { status: 500, message: "Internal Server Error" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,9 @@ function transformNrcc(input: any): NrccMessage[] | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transformTrainServices(input: any): TrainServices[] {
|
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 services: any = input?.service;
|
||||||
let output: TrainServices[] = [];
|
let output: TrainServices[] = [];
|
||||||
if (services === undefined) {
|
if (services === undefined) {
|
||||||
@ -150,7 +152,9 @@ export function calculateLength(input: any): number | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transformUnspecifiedDateTime(input: string): Date | 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) {
|
if (!input) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -41,18 +41,22 @@ describe("Remove non-Alpha", () => {
|
|||||||
const desired = outputs[key];
|
const desired = outputs[key];
|
||||||
test(`Should return with only letters: ${key}`, () => {
|
test(`Should return with only letters: ${key}`, () => {
|
||||||
expect(removeNonAlpha(input)).toEqual(desired);
|
expect(removeNonAlpha(input)).toEqual(desired);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
describe("Remove non-alphanumeric", () => {
|
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"];
|
const outputs = ["DROPcommentsampletable", "10DROPTABLEmembers", "1F44"];
|
||||||
for (const key in inputs) {
|
for (const key in inputs) {
|
||||||
const input = inputs[key];
|
const input = inputs[key];
|
||||||
const desired = outputs[key];
|
const desired = outputs[key];
|
||||||
test(`Should return with only alphanumeric: ${key}`, () => {
|
test(`Should return with only alphanumeric: ${key}`, () => {
|
||||||
expect(removeNonAlphanumeric(input)).toEqual(desired);
|
expect(removeNonAlphanumeric(input)).toEqual(desired);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user