Skip to content

Commit

Permalink
Merge pull request #356 from USEPA/feature/update-status-api-endpoints
Browse files Browse the repository at this point in the history
Feature/update status api endpoints
  • Loading branch information
courtneymyers authored Sep 13, 2023
2 parents c538a36 + ce635b9 commit 532a5bc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/server/app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ router.use("/api/bap", require("./bap"));
router.use("/api/formio/2022", require("./formio2022"));
router.use("/api/formio/2023", require("./formio2023"));
router.use("/api/help", require("./help"));
router.use("/status", require("./status"));
router.use("/api/status", require("./status"));

module.exports = router;
47 changes: 28 additions & 19 deletions app/server/app/routes/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ const express = require("express");
const { axiosFormio, formUrl } = require("../config/formio");
const { getSamEntities } = require("../utilities/bap");

/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
function verifySchema(schema) {
return schema.type === "form" && !!schema.title;
}

const router = express.Router();

router.get("/app", (req, res) => {
return res.json({ status: true });
});

router.get("/bap-sam-data", (req, res) => {
router.get("/bap/sam", (req, res) => {
getSamEntities(req, "[email protected]")
.then((bapRes) => {
if (!Array.isArray(bapRes)) {
Expand All @@ -24,50 +32,51 @@ router.get("/bap-sam-data", (req, res) => {
});
});

router.get("/formio-application-schema", (req, res) => {
router.get("/formio/2022/frf", (req, res) => {
axiosFormio(req)
.get(formUrl["2022"].frf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
return res.json({ status: schema.type === "form" && !!schema.title });
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
return res.json({ status: false });
});
});

router.get("/formio-payment-request-schema", (req, res) => {
router.get("/formio/2022/prf", (req, res) => {
axiosFormio(req)
.get(formUrl["2022"].prf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
return res.json({ status: schema.type === "form" && !!schema.title });
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
return res.json({ status: false });
});
});

router.get("/formio-close-out-schema", (req, res) => {
router.get("/formio/2022/crf", (req, res) => {
axiosFormio(req)
.get(formUrl["2022"].crf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
return res.json({ status: schema.type === "form" && !!schema.title });
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
return res.json({ status: false });
});
});

router.get("/formio/2023/frf", (req, res) => {
axiosFormio(req)
.get(formUrl["2023"].frf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
Expand Down
32 changes: 22 additions & 10 deletions docs/csb-openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@
"parameters": [{ "$ref": "#/components/parameters/scan" }]
}
},
"/status/app": {
"/api/status/app": {
"get": {
"summary": "/status/app",
"summary": "/api/status/app",
"responses": {
"200": {
"description": "OK"
Expand All @@ -118,9 +118,9 @@
"parameters": [{ "$ref": "#/components/parameters/scan" }]
}
},
"/status/bap-sam-data": {
"/api/status/bap/sam": {
"get": {
"summary": "/status/bap-sam-data",
"summary": "/api/status/bap/sam",
"responses": {
"200": {
"description": "OK"
Expand All @@ -130,9 +130,9 @@
"parameters": [{ "$ref": "#/components/parameters/scan" }]
}
},
"/status/formio-application-schema": {
"/api/status/formio/2022/frf": {
"get": {
"summary": "/status/formio-application-schema",
"summary": "/api/status/formio/2022/frf",
"responses": {
"200": {
"description": "OK"
Expand All @@ -142,9 +142,9 @@
"parameters": [{ "$ref": "#/components/parameters/scan" }]
}
},
"/status/formio-payment-request-schema": {
"/api/status/formio/2022/prf": {
"get": {
"summary": "/status/formio-payment-request-schema",
"summary": "/api/status/formio/2022/prf",
"responses": {
"200": {
"description": "OK"
Expand All @@ -154,9 +154,21 @@
"parameters": [{ "$ref": "#/components/parameters/scan" }]
}
},
"/status/formio-close-out-schema": {
"/api/status/formio/2022/crf": {
"get": {
"summary": "/status/formio-close-out-schema",
"summary": "/api/status/formio/2022/crf",
"responses": {
"200": {
"description": "OK"
}
},
"tags": [],
"parameters": [{ "$ref": "#/components/parameters/scan" }]
}
},
"/api/status/formio/2023/frf": {
"get": {
"summary": "/api/status/formio/2023/frf",
"responses": {
"200": {
"description": "OK"
Expand Down

0 comments on commit 532a5bc

Please sign in to comment.