Skip to content

Commit 1c8b46f

Browse files
feat(oidc-http-server-pages): generate JSON templates COMPASS-7646 (#246)
Co-authored-by: Anna Henningsen <[email protected]>
1 parent 351d213 commit 1c8b46f

File tree

14 files changed

+474
-253
lines changed

14 files changed

+474
-253
lines changed

package-lock.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/devtools-connect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"license": "Apache-2.0",
4949
"dependencies": {
50-
"@mongodb-js/oidc-http-server-pages": "0.1.1",
50+
"@mongodb-js/oidc-http-server-pages": "1.0.0",
5151
"lodash.merge": "^4.6.2",
5252
"mongodb-connection-string-url": "^3.0.0",
5353
"socks": "^2.7.3",

packages/devtools-connect/src/oidc/handler.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { RedirectServerRequestInfo } from '@mongodb-js/oidc-plugin';
22
import type { DevtoolsConnectOptions } from '../connect';
33
import {
4-
OIDCAcceptedPage,
5-
OIDCNotFoundPage,
6-
OIDCErrorPage,
4+
getStaticPage,
5+
HttpServerPage,
76
} from '@mongodb-js/oidc-http-server-pages';
87

98
export function oidcServerRequestHandler(
@@ -31,13 +30,31 @@ export function oidcServerRequestHandler(
3130

3231
switch (result) {
3332
case 'accepted':
34-
res.end(OIDCAcceptedPage({ productDocsLink, productName }));
33+
res.end(
34+
getStaticPage(HttpServerPage.OIDCAcceptedPage, {
35+
productDocsLink,
36+
productName,
37+
})
38+
);
3539
break;
3640
case 'rejected':
37-
res.end(OIDCErrorPage({ productDocsLink, productName, ...info }));
41+
res.end(
42+
getStaticPage(HttpServerPage.OIDCErrorPage, {
43+
productDocsLink,
44+
productName,
45+
error: info.error,
46+
errorDescription: info.errorDescription,
47+
errorURI: info.errorURI,
48+
})
49+
);
3850
break;
3951
default:
40-
res.end(OIDCNotFoundPage({ productDocsLink, productName }));
52+
res.end(
53+
getStaticPage(HttpServerPage.OIDCNotFoundPage, {
54+
productDocsLink,
55+
productName,
56+
})
57+
);
4158
break;
4259
}
4360
}

packages/oidc-http-server-pages/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"email": "[email protected]"
1414
},
1515
"homepage": "https://github.com/mongodb-js/devtools-shared",
16-
"version": "0.1.1",
16+
"version": "1.0.0",
1717
"repository": {
1818
"type": "git",
1919
"url": "https://github.com/mongodb-js/devtools-shared.git"
@@ -31,15 +31,15 @@
3131
"scripts": {
3232
"bootstrap": "npm run compile",
3333
"prepublishOnly": "npm run compile",
34-
"compile": "tsc -p tsconfig.json && node dist/create-static-pages.js > dist/static-pages.js && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
34+
"compile": "tsc -p tsconfig.json && node dist/create-templates.js && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
3535
"typecheck": "tsc --noEmit",
3636
"eslint": "eslint",
3737
"prettier": "prettier",
3838
"lint": "npm run eslint . && npm run prettier -- --check .",
3939
"depcheck": "depcheck",
4040
"check": "npm run typecheck && npm run lint && npm run depcheck",
4141
"check-ci": "npm run check",
42-
"test": "mocha",
42+
"test": "npm run compile && mocha",
4343
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
4444
"test-watch": "npm run test -- --watch",
4545
"test-ci": "npm run test-cov",
@@ -55,7 +55,6 @@
5555
"@leafygreen-ui/emotion": "^4.0.7",
5656
"@types/chai": "^4.2.21",
5757
"@types/mocha": "^9.1.1",
58-
"@types/node": "^17.0.35",
5958
"@types/react": "^17.0.53",
6059
"@types/react-dom": "^17.0.19",
6160
"@types/sinon-chai": "^3.2.5",
@@ -68,8 +67,6 @@
6867
"prettier": "^2.3.2",
6968
"react": "^17.0.2",
7069
"react-dom": "^17.0.2",
71-
"sinon-chai": "^3.7.0",
72-
"ts-sinon": "^2.0.1",
7370
"typescript": "^5.0.4"
7471
}
7572
}

packages/oidc-http-server-pages/src/create-static-pages.spec.tsx

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

packages/oidc-http-server-pages/src/create-static-pages.ts

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

0 commit comments

Comments
 (0)