Shared data model between multiple apps?


I currently have one Meteor project where I host both the app available for users and the admin app. I want to split this into 2 different Meteor projects.

One reason I liked having the 2 in one project, is that I share some server code. For example, I have functions to do checks on the formats of the fields of each object. When I split the project, I’d like to still be able to use functions that I share, for example those functions that ensure the data format. That way I’m sure the data is in the right format when inserting and updating, and I don’t want to maintain that logic in multiples places/apps).

What is the best practice around this?


The best way to handle that would be to use dynamic imports

You can also break them out and publish as smaller modules to NPM and use a private NPM organization if you don’t want to open source anything. This allows you to do updates and pin versions if needed from a central place.

Yeah dynamic imports will let you use exact code splitting to separate public from admin while staying in the one project.

If you want to completely separate it, you can use DDP.connect to connect to the other Meteor server and subscribe to it’s data and call it’s methods.