newStaffLDB-API #48

Merged
fred.boniface merged 85 commits from newStaffLDB-API into main 2023-10-03 21:35:03 +01:00
Showing only changes of commit be9fb68c3d - Show all commits

View File

@ -1,4 +1,3 @@
/* eslint-disable no-useless-escape */
//const axios = require("axios"); //const axios = require("axios");
import { logger } from "../utils/logger.utils"; import { logger } from "../utils/logger.utils";
@ -20,25 +19,29 @@ async function processor(data) {
} }
async function sendToGitea(body) { async function sendToGitea(body) {
let key = process.env.OWL_GIT_ISSUEBOT; try {
let url = process.env.OWL_GIT_APIENDPOINT; const key = process.env.OWL_GIT_ISSUEBOT;
let opts = { const url = process.env.OWL_GIT_APIENDPOINT;
const opts = {
method: "POST", method: "POST",
headers: { headers: {
Authorization: key, Authorization: key,
}, },
body: body, body: body,
}; };
//var res = await axios.post(url, body, opts);
const res = await fetch(url, opts); const res = await fetch(url, opts);
/* Need to read the output from the POST and pass the result upwards to the
client.*/ if (res.status === 201) {
if (res.status == 201) { logger.debug("issueService.sendToGitea: Issue created");
logger.info("issueService.sendToGitea: Issue sent to Gitea"); return {status: res.status, message: "issue created"};
return { status: res.status, message: "issue created" };
} else { } else {
logger.error(res.body, "issueService.sendToGitea: Fail to send issue"); logger.error(`issueService.sendtoGitea: Error creating issue RETURN: ${res.status}`);
return { status: res.status, message: "issue not created" }; return {status: res.status, message: "issue not created"};
}
} catch (err) {
logger.error(err, `issueService.sendToGitea`);
return {status:500, message: "Internal Server Error"};
} }
} }