Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: exporting AllRoutes set from generated ROUTES.ts #676

Merged
merged 7 commits into from
Jul 25, 2024

Conversation

duducpp
Copy link
Contributor

@duducpp duducpp commented Jul 17, 2024

This allows users to access all routes generated through a Set.

export type AllRoutes<T = AllTypes, K = keyof T> = K extends \`\${infer I1} \${infer I2}\` ? I2 : K
export const allRoutes = [... new Set(Object.keys(AllObjs).map((k) => /^\\/.*|[^ ]?\\/.*$/.exec(k)?.[0] ?? null))]

Result:

// type AllRoutes
"/" | "/route1" | "/route2/[alias]"

// const allRoutes
["/", "/route1", "/route2/[alias]"]

This allows users to import 'AllObjs' which contains all routes.
@duducpp duducpp changed the title feat: exporting AllObjs from generated ROUTES.ts feat: exporting AllRoutes set from generated ROUTES.ts Jul 17, 2024
@jycouet
Copy link
Owner

jycouet commented Jul 17, 2024

Looks good to me thx.

I don't have access to a laptop RN, I'll look at it next week. Hope it's ok for you.

Copy link

nx-cloud bot commented Jul 25, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1c4ad59. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@jycouet
Copy link
Owner

jycouet commented Jul 25, 2024

@all-contributors please add @duducpp for code

Copy link
Contributor

@jycouet

I've put up a pull request to add @duducpp! 🎉

@jycouet jycouet merged commit 99c9786 into jycouet:main Jul 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants