Skip to content

Commit

Permalink
src: use itty-router for routing requests
Browse files Browse the repository at this point in the history
Closes #122

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
  • Loading branch information
flakey5 committed Aug 5, 2024
1 parent ea537f0 commit b7db0cf
Show file tree
Hide file tree
Showing 57 changed files with 1,085 additions and 2,292 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"ignoreRestSiblings": true
}
],
"@typescript-eslint/explicit-function-return-type": "error"
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/consistent-type-imports": "error"
}
}
]
Expand Down
4 changes: 0 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Default rules

* @nodejs/web-infra

# Node.js build paths

/src/constants/r2Prefixes.ts @nodejs/build
2 changes: 1 addition & 1 deletion .github/workflows/update-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: npm install && npm update nodejs-latest-linker

- name: Update Redirect Links
run: node scripts/update-redirect-links.js && npm run format
run: node scripts/update-latest-versions.js && npm run format
env:
CF_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }}
CF_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }}
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"glob": "^10.3.10",
"nodejs-latest-linker": "^1.7.0",
"prettier": "^3.0.3",
"terser": "^5.20.0",
"tsx": "^4.7.2",
"typescript": "^5.2.2",
"wrangler": "^3.22.1",
"nodejs-latest-linker": "^1.7.0"
"wrangler": "^3.22.1"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.423.0",
"handlebars": "^4.7.8",
"itty-router": "^5.0.17",
"toucan-js": "^3.3.1",
"zod": "^3.22.3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@ const client = new S3Client({
(async function main() {
const allDirs = await listDirectory(RELEASE_DIR);
const linker = new Linker({ baseDir: RELEASE_DIR, docsDir: DOCS_DIR });
const links = await linker.getLinks(allDirs, dir => listDirectory(`${dir}/`));
const allLinks = await linker.getLinks(allDirs, dir =>
listDirectory(`${dir}/`)
);

const latestLinks = Array.from(allLinks).filter(link =>
link[0].startsWith('nodejs/release')
);
latestLinks.forEach(link => {
link[0] = link[0].substring('nodejs/release/'.length);
link[1] = link[1].substring('nodejs/release/'.length);
});

await writeFile(
'./src/constants/redirectLinks.json',
JSON.stringify(Array.from(links), null, 2) + '\n'
'./src/constants/latestVersions.json',
JSON.stringify(Object.fromEntries(latestLinks), null, 2) + '\n'
);
})();

Expand Down
2 changes: 0 additions & 2 deletions src/constants/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const CACHE = caches.default;

export const CACHE_HEADERS = {
success: 'public, max-age=3600, s-maxage=14400',
failure: 'private, no-cache, no-store, max-age=0, must-revalidate',
Expand Down
33 changes: 33 additions & 0 deletions src/constants/latestVersions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"latest-v0.10.x": "v0.10.48",
"latest-v0.12.x": "v0.12.18",
"latest-v4.x": "v4.9.1",
"latest-argon": "v4.9.1",
"latest-v5.x": "v5.12.0",
"latest-v6.x": "v6.17.1",
"latest-boron": "v6.17.1",
"latest-v7.x": "v7.10.1",
"latest-v8.x": "v8.17.0",
"latest-carbon": "v8.17.0",
"latest-v9.x": "v9.11.2",
"latest-v10.x": "v10.24.1",
"latest-dubnium": "v10.24.1",
"latest-v11.x": "v11.15.0",
"latest-v12.x": "v12.22.12",
"latest-erbium": "v12.22.12",
"latest-v13.x": "v13.14.0",
"latest-v14.x": "v14.21.3",
"latest-fermium": "v14.21.3",
"latest-v15.x": "v15.14.0",
"latest-v16.x": "v16.20.2",
"latest-gallium": "v16.20.2",
"latest-v17.x": "v17.9.1",
"latest-v18.x": "v18.19.0",
"latest-hydrogen": "v18.19.0",
"latest-v19.x": "v19.9.0",
"latest-v20.x": "v20.10.0",
"latest-iron": "v20.10.0",
"latest-v21.x": "v21.2.0",
"latest": "v21.2.0",
"node-latest.tar.gz": "v21.2.0/node-v21.2.0.tar.gz"
}
38 changes: 0 additions & 38 deletions src/constants/r2Prefixes.ts

This file was deleted.

Loading

0 comments on commit b7db0cf

Please sign in to comment.