Route in typescript DTO

In the below fragment of my generated DTOs, the route string is in the comments.

Any chance you could make it accessible programatically, for example in a const?

  // @Route("/session-to-token")
  // @DataContract
  interface ConvertSessionToToken extends IReturn<ConvertSessionToTokenResponse>

Annotations need to be enabled by default in TypeScript before we can emit them, adding any non-standard approach now will break anyone relying on the when we move to annotations in future.

You can programmatically fetch metadata about your Services at /types/metadata which also contains the Route info for each Service.

Thanks, I get it that you like to commit to standard features.

In the mean time, I still think it would be nice to have a generated class separate from the interfaces, with a string const for each route, just to safeguard against refactorings. That won’t break but would become redundant. The meta-data is nice, but requires me to do the code-gen to TypeScript.

I’ll let it be for now – I like the the whole full stack experience with ServiceStack and React/Typescript a lot BTW.

1 Like

If you’re using TypeScript why not use these DTOs with the TypeScript servicestack-client that way you won’t need to deal with manually constructing the urls yourself? e.g:

var client = new JsonServiceClient(""); GetCustomers())
    .then(r => { // r:GetCustomersResponse
    .catch(e => {
1 Like

Great tip, thanks. Did not yet read about it and we brewed up our own jQuery-based get/post.

1 Like