microsoft / microsoft/typespec
[hsj] Change router so that it can be instantiated with a record of route controllers instead of positional params
Open
emitter:service:js
feature
triaged:core
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
The generated HTTP router for the JS server generator currently accepts route controllers as positional arguments, but it should use a record or other associative structure instead. The positional nature of the router instantiation makes it sensitive to the order of declaration in TypeSpec and as new services are added the order of the route controllers is changing, requiring many changes to the `createRouter` call.
We want:
```ts
const router = createRouter({
example: new Example()
});
```
instead of:
```ts
const router = createRouter(new Example());
```
Contributor guide
Assessment
This issue has not been assessed yet.