Skip to content

Commit 202383d

Browse files
author
JAMES FUQIAN
committed
cleanup un-used artifacts and fix linting, sync with changed CI check workflow file.
1 parent 4fd4224 commit 202383d

3 files changed

Lines changed: 55 additions & 114 deletions

File tree

server/build.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

server/index.ts

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -45,65 +45,69 @@ app.get("/api/authorize/authurl", (req: Request, res: Response) => {
4545
});
4646

4747
// auth flow: oauth2 call back
48-
app.get("/api/bluebutton/callback", async (req: Request, res: Response) => {
49-
if (typeof req.query.error === "string") {
50-
// clear all cached claims eob data since the bene has denied access
51-
// for the application
52-
clearBB2Data();
53-
let errMsg = req.query.error;
54-
if (req.query.error === BENE_DENIED_ACCESS) {
55-
errMsg = FE_MSG_ACCESS_DENIED;
56-
}
57-
loggedInUser.eobData = {"message": errMsg};
58-
process.stdout.write(errMsg + '\n');
59-
} else {
60-
if (
61-
typeof req.query.code === "string" &&
62-
typeof req.query.state === "string"
63-
) {
64-
try {
65-
authToken = await bb.getAuthorizationToken(
66-
authData,
67-
req.query.code,
68-
req.query.state
69-
);
70-
// data flow: after access granted
71-
// the app logic can fetch the beneficiary's data in app specific ways:
72-
// e.g. download EOB periodically etc.
73-
// access token can expire, SDK automatically refresh access token when that happens.
74-
const eobResults = await bb.getExplanationOfBenefitData(authToken);
75-
authToken = eobResults.token; // in case authToken got refreshed during fhir call
76-
77-
loggedInUser.authToken = authToken;
78-
79-
loggedInUser.eobData = eobResults.response?.data;
80-
} catch (e) {
81-
loggedInUser.eobData = {};
82-
process.stdout.write(ERR_QUERY_EOB + '\n');
83-
process.stdout.write("Exception: " + e + '\n');
48+
app.get("/api/bluebutton/callback", (req: Request, res: Response) => {
49+
(async (req: Request, res: Response) => {
50+
if (typeof req.query.error === "string") {
51+
// clear all cached claims eob data since the bene has denied access
52+
// for the application
53+
clearBB2Data();
54+
let errMsg = req.query.error;
55+
if (req.query.error === BENE_DENIED_ACCESS) {
56+
errMsg = FE_MSG_ACCESS_DENIED;
57+
}
58+
loggedInUser.eobData = {"message": errMsg};
59+
process.stdout.write(errMsg + '\n');
60+
} else {
61+
if (
62+
typeof req.query.code === "string" &&
63+
typeof req.query.state === "string"
64+
) {
65+
try {
66+
authToken = await bb.getAuthorizationToken(
67+
authData,
68+
req.query.code,
69+
req.query.state
70+
);
71+
// data flow: after access granted
72+
// the app logic can fetch the beneficiary's data in app specific ways:
73+
// e.g. download EOB periodically etc.
74+
// access token can expire, SDK automatically refresh access token when that happens.
75+
const eobResults = await bb.getExplanationOfBenefitData(authToken);
76+
authToken = eobResults.token; // in case authToken got refreshed during fhir call
77+
78+
loggedInUser.authToken = authToken;
79+
80+
loggedInUser.eobData = eobResults.response?.data;
81+
} catch (e) {
82+
loggedInUser.eobData = {};
83+
process.stdout.write(ERR_QUERY_EOB + '\n');
84+
process.stdout.write("Exception: " + e + '\n');
85+
}
86+
} else {
87+
clearBB2Data();
88+
process.stdout.write(ERR_MISSING_AUTH_CODE + '\n');
89+
process.stdout.write("OR" + '\n');
90+
process.stdout.write(ERR_MISSING_STATE + '\n');
91+
process.stdout.write("AUTH CODE: " + req.query.code + '\n');
92+
process.stdout.write("STATE: " + req.query.state + '\n');
93+
}
94+
}
95+
const fe_redirect_url =
96+
process.env.SELENIUM_TESTS ? 'http://client:3000' : 'http://localhost:3000';
97+
res.redirect(fe_redirect_url);
8498
}
85-
} else {
86-
clearBB2Data();
87-
process.stdout.write(ERR_MISSING_AUTH_CODE + '\n');
88-
process.stdout.write("OR" + '\n');
89-
process.stdout.write(ERR_MISSING_STATE + '\n');
90-
process.stdout.write("AUTH CODE: " + req.query.code + '\n');
91-
process.stdout.write("STATE: " + req.query.state + '\n');
92-
}
93-
}
94-
const fe_redirect_url =
95-
process.env.SELENIUM_TESTS ? 'http://client:3000' : 'http://localhost:3000';
96-
res.redirect(fe_redirect_url);
99+
)(req, res);
97100
});
98101

99102
// data flow: front end fetch eob
100-
app.get("/api/data/benefit", async (req: Request, res: Response) => {
103+
app.get("/api/data/benefit", (req: Request, res: Response) => {
101104
if (loggedInUser.eobData) {
102105
res.json(loggedInUser.eobData);
103106
}
104107
});
105108

106109
const port = 3001;
107110
app.listen(port, () => {
108-
console.log(`[server]: Server is running at https://localhost:${port}`);
111+
process.stdout.write(`[server]: Server is running at https://localhost:${port}`);
112+
process.stdout.write("\n");
109113
});

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "CMS Blue Button API team",
66
"license": "MIT",
77
"scripts": {
8-
"lint": "eslint --fix --ext .ts --ext .tsx .",
8+
"lint": "eslint --fix --ext .ts --ext .tsx index.ts",
99
"start": "node ./node_modules/.bin/ts-node -r tsconfig-paths/register .",
1010
"start:debug": "node --inspect=0.0.0.0:9229 ./node_modules/.bin/ts-node -r tsconfig-paths/register ."
1111
},

0 commit comments

Comments
 (0)