demo-ionic-nest-tutorial
demo-ionic-nest-tutorial copied to clipboard
Question: SHARED Package
Dear @elylucas , ionic team and community,
thank you very much for this nice tutorial on how to build a backend (with NestJS) and frontend (with Ionic) and the corresponding starter package here. However, i was wondering, if it would be possible to add some kind of shared package (besides the client and server package) that share some common models and interfaces.
Currently, for example, the server has strongly typed classes (e.g., the Mission
), however, the client does not get this model definition.
On the one hand, this would reduce the need to maintain the same structures on client and server side. On the other, both parts (client & server) would work with / on the same structures. What do you think about this?
All the best
@johannesschobel , Have you discovered a way to share code between Nest and Ionic, as you mentioned?
Dear @ModestinoAndre ,
thank you very much for picking up this issue. I switched to nrwl/nx
(https://github.com/nrwl/nx), which is a framework that allows building multiple applications within one large workspace (i.e., a monorepository pattern).
Nx
has generators for nest, angular and via 3rd party packages for ionic as well.
In this context, you can easily create a nrwl/workspace:lib
that can be shared between client and server. This allows, for example, for creating some kind of shared interface package.
For more details, check out the Nrwl/Nx tutorial here (https://nx.dev/latest/angular/tutorial/01-create-application). Especially part 7 focusses on sharing data between client and server.
Hope this helps!