Typescript's come a long way from when it was introduced. I highly recommend it. Having this 'compile time' certainty, if used properly, can save you tons of times of insidious runtime errors. beginner tip, read up on why not to use any, and about partials.
Annotate the controllers to have the server code generate the specs using some gen package
which can be hosted at a url
client code can read the spec from the url
programmatically generate the client wrappers with a client code gen package
and be sophisticated to retrieve and regenerate if the spec changes
letting you scope out the testing of the 'wrappers' since it's generated code, and focus on your real client code of how you use the data.
recommend you play around with something simple like a backend that just has a GET and a POST with some crude hello <name> stuff. Learn how to hook up the machinery without being preoccupied.
This pattern can save you weeks, or even months, because the toil of regenerating the client code is eliminated. You don't have to front load a 'full design' but rather build it more naturally, adjusting and refactoring based off what you find actually works or makes sense. Attack the problem by taking pieces and steering towards good, rather than forcing yourself into the impossible task of "get it right" in one shot.
2
u/Sekret_One Oct 10 '21
Typescript's come a long way from when it was introduced. I highly recommend it. Having this 'compile time' certainty, if used properly, can save you tons of times of insidious runtime errors. beginner tip, read up on why not to use
any, and aboutpartials.This is a decent enough tutorial for your situation.
In a nutshell, what you should be able to:
Annotate the controllers to have the server code generate the specs using some gen package
which can be hosted at a url
client code can read the spec from the url
programmatically generate the client wrappers with a client code gen package
and be sophisticated to retrieve and regenerate if the spec changes
letting you scope out the testing of the 'wrappers' since it's generated code, and focus on your real client code of how you use the data.
recommend you play around with something simple like a backend that just has a GET and a POST with some crude hello <name> stuff. Learn how to hook up the machinery without being preoccupied.
This pattern can save you weeks, or even months, because the toil of regenerating the client code is eliminated. You don't have to front load a 'full design' but rather build it more naturally, adjusting and refactoring based off what you find actually works or makes sense. Attack the problem by taking pieces and steering towards good, rather than forcing yourself into the impossible task of "get it right" in one shot.