Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[RFC] Enforce dot-notation in sub-routers #115

Closed
KATT opened this issue Mar 1, 2021 · 3 comments
Closed

[RFC] Enforce dot-notation in sub-routers #115

KATT opened this issue Mar 1, 2021 · 3 comments

Comments

@KATT
Copy link
Member

KATT commented Mar 1, 2021

Initially when writing trpc>1 I was thinking I would use / as a separator between sub-routers, but it's more readable to have the whole path written out.

I've forgotten to add the . at the end a few times when creating sub-routers and it's a bit annoying. Don't see any harm in enforcing it.

This would be a major version change, but easy refactor - could be done application-wide with a simple regex.

Change proposal

Before

const appRouter = createRouter()
  .merge('users.', users) // prefix user procedures with "users."
  .merge('posts.', posts) // prefix poosts procedures with "posts."
  ;

After

const appRouter = createRouter()
  .merge('users', users) // prefix user procedures with "users."
  .merge('posts', posts) // prefix poosts procedures with "posts."
  ;
@KATT
Copy link
Member Author

KATT commented Mar 1, 2021

cc @cyrus-za

@cyrus-za
Copy link
Contributor

cyrus-za commented Mar 3, 2021

I think this can be achieved without making it a breaking change. Can have automatic alias for ones without it and then add a linting rule or something? But I am fine with making another major version. Which ever works for you.

I like the idea though. I've also ran into it

@KATT
Copy link
Member Author

KATT commented Mar 3, 2021

Sure, I could make a minor version with a deprecation warning!

@KATT KATT closed this as completed Apr 12, 2021
@trpc trpc locked and limited conversation to collaborators Apr 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants