Let's say I have a /createPost POST endpoint in my nestjs backend. The request and response object should be fully typed in the backend via the DTO. However, how do I bring these types into the frontend? I would like to have a typed post request object, so I can not enter invalid fields or missing fields in the post body. I would also like to have a typescript interface for the response. I want to REUSE the code from the backend. What's the best way to go about this? Is there some sort of type generator library?
↧