diff --git a/package.json b/package.json index b8ee457d..f39377bb 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "open-source" ], "dependencies": { + "@octokit/rest": "^20.0.2", "dotenv": "^16.3.1" }, "devDependencies": { diff --git a/static/main.ts b/static/main.ts index c81c1db2..31531515 100644 --- a/static/main.ts +++ b/static/main.ts @@ -1,28 +1,30 @@ +import { Octokit } from "@octokit/rest"; import { GitHubIssue } from "./github-types"; export async function mainModule() { await fetchIssues(); async function fetchIssues() { - const container = document.getElementById('issues-container'); + const container = document.getElementById("issues-container"); if (!container) { - throw new Error('Could not find issues container'); + throw new Error("Could not find issues container"); } - container.innerHTML = '
Loading issues...
'; + container.innerHTML = "Loading issues...
"; try { - const cachedIssues = localStorage.getItem('githubIssues'); - let issues; + const cachedIssues = localStorage.getItem("githubIssues"); + let issues: GitHubIssue[]; + + const octokit = new Octokit(); + const freshIssues = await octokit.paginate("GET /repos/ubiquity/devpool-directory/issues") as GitHubIssue[]; if (cachedIssues) { issues = JSON.parse(cachedIssues); + // Update the cache with fresh issues + localStorage.setItem("githubIssues", JSON.stringify(freshIssues)); } else { - const response = await fetch('https://api.github.com/repos/ubiquity/devpool-directory/issues'); - if (!response.ok) { - throw new Error(`Error: ${response.status}`); - } - issues = await response.json(); - localStorage.setItem('githubIssues', JSON.stringify(issues)); + issues = freshIssues; + localStorage.setItem("githubIssues", JSON.stringify(issues)); } const sortedIssues = sortIssuesByComments(issues); @@ -55,7 +57,6 @@ export async function mainModule() { return 0; }); } - } mainModule() .then(() => { diff --git a/static/style.css b/static/style.css index 76ef4ef1..b4f9a6a9 100644 --- a/static/style.css +++ b/static/style.css @@ -1,4 +1,4 @@ -body{ +body { font-family: "Proxima Nova", "Ubiquity Nova", sans-serif; background-color: #06061aff; color: #fff; @@ -9,7 +9,9 @@ body{ font-style: normal; font-weight: 400; src: url(./fonts/ubiquity-nova-standard.eot); - src: url(./fonts/ubiquity-nova-standard.eot#iefix) format("embedded-opentype"), url(./fonts/ubiquity-nova-standard.woff) format("woff"), + src: + url(./fonts/ubiquity-nova-standard.eot#iefix) format("embedded-opentype"), + url(./fonts/ubiquity-nova-standard.woff) format("woff"), url(./fonts/ubiquity-nova-standard.ttf) format("truetype"); } diff --git a/tsconfig.json b/tsconfig.json index bb2f7f66..fb96ead8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -55,7 +55,7 @@ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "./static/dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ diff --git a/yarn.lock b/yarn.lock index fd6183ac..41f632e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -705,6 +705,131 @@ __metadata: languageName: node linkType: hard +"@octokit/auth-token@npm:^4.0.0": + version: 4.0.0 + resolution: "@octokit/auth-token@npm:4.0.0" + checksum: d78f4dc48b214d374aeb39caec4fdbf5c1e4fd8b9fcb18f630b1fe2cbd5a880fca05445f32b4561f41262cb551746aeb0b49e89c95c6dd99299706684d0cae2f + languageName: node + linkType: hard + +"@octokit/core@npm:^5.0.0": + version: 5.0.2 + resolution: "@octokit/core@npm:5.0.2" + dependencies: + "@octokit/auth-token": ^4.0.0 + "@octokit/graphql": ^7.0.0 + "@octokit/request": ^8.0.2 + "@octokit/request-error": ^5.0.0 + "@octokit/types": ^12.0.0 + before-after-hook: ^2.2.0 + universal-user-agent: ^6.0.0 + checksum: 9ce060d61577f6805901ae5c33b2764a441db119ae0cca09104adf37b119cce68b656220de56c0c5004c9c9c1c892a7fdfbe9c0b1f5e398cb359dfd39c57eca8 + languageName: node + linkType: hard + +"@octokit/endpoint@npm:^9.0.0": + version: 9.0.4 + resolution: "@octokit/endpoint@npm:9.0.4" + dependencies: + "@octokit/types": ^12.0.0 + universal-user-agent: ^6.0.0 + checksum: ed1b64a448f478e5951a043ef816d634a5a1f584519cbf2f374ceac058f82a16e52f078f156aa8b8cbcab7b0590348d94294fc83c9b4eebd42a820a5f10db81c + languageName: node + linkType: hard + +"@octokit/graphql@npm:^7.0.0": + version: 7.0.2 + resolution: "@octokit/graphql@npm:7.0.2" + dependencies: + "@octokit/request": ^8.0.1 + "@octokit/types": ^12.0.0 + universal-user-agent: ^6.0.0 + checksum: 05a752c4c2d84fc2900d8e32e1c2d1ee98a5a14349e651cb1109d0741e821e7417a048b1bb40918534ed90a472314aabbda35688868016f248098925f82a3bfa + languageName: node + linkType: hard + +"@octokit/openapi-types@npm:^19.0.2": + version: 19.1.0 + resolution: "@octokit/openapi-types@npm:19.1.0" + checksum: 9d1b188741609a9832b964df2bc337ee77c1fc89d5f686faebb743c7cb27721e214180d623ee28227427b4c43719b79ee4890e338a709b78a9f249a7c369ac3e + languageName: node + linkType: hard + +"@octokit/plugin-paginate-rest@npm:^9.0.0": + version: 9.1.4 + resolution: "@octokit/plugin-paginate-rest@npm:9.1.4" + dependencies: + "@octokit/types": ^12.3.0 + peerDependencies: + "@octokit/core": ">=5" + checksum: 5a8332f0faa1480c0dcd4dd097100b80c5f61a42dcab689342db367dec4211af131b3e53b8b832577b2191ee75c78423f30f5d1a1b5797d789dd33f7860e1037 + languageName: node + linkType: hard + +"@octokit/plugin-request-log@npm:^4.0.0": + version: 4.0.0 + resolution: "@octokit/plugin-request-log@npm:4.0.0" + peerDependencies: + "@octokit/core": ">=5" + checksum: 2a8a6619640942092009a9248ceeb163ce01c978e2d7b2a7eb8686bd09a04b783c4cd9071eebb16652d233587abcde449a02ce4feabc652f0a171615fb3e9946 + languageName: node + linkType: hard + +"@octokit/plugin-rest-endpoint-methods@npm:^10.0.0": + version: 10.2.0 + resolution: "@octokit/plugin-rest-endpoint-methods@npm:10.2.0" + dependencies: + "@octokit/types": ^12.3.0 + peerDependencies: + "@octokit/core": ">=5" + checksum: 3209688bf508d22a525fe32d632ff928b048688c1859c7e4bbb08bd181aa07f580b375a502e34368628103e5d5cccf7f9fb0ff0c8fd4262470ac8eeffb80ac6b + languageName: node + linkType: hard + +"@octokit/request-error@npm:^5.0.0": + version: 5.0.1 + resolution: "@octokit/request-error@npm:5.0.1" + dependencies: + "@octokit/types": ^12.0.0 + deprecation: ^2.0.0 + once: ^1.4.0 + checksum: a681341e43b4da7a8acb19e1a6ba0355b1af146fa0191f2554a98950cf85f898af6ae3ab0b0287d6c871f5465ec57cb38363b96b5019f9f77ba6f30eca39ede5 + languageName: node + linkType: hard + +"@octokit/request@npm:^8.0.1, @octokit/request@npm:^8.0.2": + version: 8.1.6 + resolution: "@octokit/request@npm:8.1.6" + dependencies: + "@octokit/endpoint": ^9.0.0 + "@octokit/request-error": ^5.0.0 + "@octokit/types": ^12.0.0 + universal-user-agent: ^6.0.0 + checksum: df90204586ee7db5adf69c3007c5d9c0a866de488c9ba8756f98083208726ed360d5a541e68204c413fa10e6f17e171dc9868b18768b9799df0003bc84c59cf2 + languageName: node + linkType: hard + +"@octokit/rest@npm:^20.0.2": + version: 20.0.2 + resolution: "@octokit/rest@npm:20.0.2" + dependencies: + "@octokit/core": ^5.0.0 + "@octokit/plugin-paginate-rest": ^9.0.0 + "@octokit/plugin-request-log": ^4.0.0 + "@octokit/plugin-rest-endpoint-methods": ^10.0.0 + checksum: 5c56ac23f063a5375ae5a0609e6477d90afac872eccd07002870f9dd62755037282a74c15c90c848b76b64ea4b5af52f32720b8a1b7b133e758118d11d2c0e34 + languageName: node + linkType: hard + +"@octokit/types@npm:^12.0.0, @octokit/types@npm:^12.3.0": + version: 12.3.0 + resolution: "@octokit/types@npm:12.3.0" + dependencies: + "@octokit/openapi-types": ^19.0.2 + checksum: ba852690b7dcdf0d01e68b2dba79b1823322406493bfb769964e07b0ee47005d58a0241e401afb6e03f0ab51ecd7a739d6d3e4d0cc1db8b7606c36c8a2104e67 + languageName: node + linkType: hard + "@pkgjs/parseargs@npm:0.11.0, @pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0" @@ -1298,6 +1423,13 @@ __metadata: languageName: node linkType: hard +"before-after-hook@npm:^2.2.0": + version: 2.2.3 + resolution: "before-after-hook@npm:2.2.3" + checksum: a1a2430976d9bdab4cd89cb50d27fa86b19e2b41812bf1315923b0cba03371ebca99449809226425dd3bcef20e010db61abdaff549278e111d6480034bebae87 + languageName: node + linkType: hard + "bole@npm:^5.0.0": version: 5.0.9 resolution: "bole@npm:5.0.9" @@ -1757,6 +1889,13 @@ __metadata: languageName: node linkType: hard +"deprecation@npm:^2.0.0": + version: 2.3.1 + resolution: "deprecation@npm:2.3.1" + checksum: f56a05e182c2c195071385455956b0c4106fe14e36245b00c689ceef8e8ab639235176a96977ba7c74afb173317fac2e0ec6ec7a1c6d1e6eaa401c586c714132 + languageName: node + linkType: hard + "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -4151,7 +4290,7 @@ __metadata: languageName: node linkType: hard -"once@npm:^1.3.0": +"once@npm:^1.3.0, once@npm:^1.4.0": version: 1.4.0 resolution: "once@npm:1.4.0" dependencies: @@ -5261,6 +5400,7 @@ __metadata: dependencies: "@commitlint/cli": ^18.4.3 "@commitlint/config-conventional": ^18.4.3 + "@octokit/rest": ^20.0.2 "@types/node": ^20.10.0 "@typescript-eslint/eslint-plugin": ^6.13.1 "@typescript-eslint/parser": ^6.13.1 @@ -5430,6 +5570,13 @@ __metadata: languageName: node linkType: hard +"universal-user-agent@npm:^6.0.0": + version: 6.0.1 + resolution: "universal-user-agent@npm:6.0.1" + checksum: fdc8e1ae48a05decfc7ded09b62071f571c7fe0bd793d700704c80cea316101d4eac15cc27ed2bb64f4ce166d2684777c3198b9ab16034f547abea0d3aa1c93c + languageName: node + linkType: hard + "universalify@npm:^2.0.0": version: 2.0.0 resolution: "universalify@npm:2.0.0"