5

I'm new to MeteorJS and I think it's a better alternative to the MEAN stack I used in one of my projects. I like the angular-meteor package (https://github.com/Urigo/angular-meteor) but I think it's mainly for adding AngularJS support to a MeteorJS app and not the other way around.

How would you approach adding MeteorJS to an existing AngularJS or MEAN stack app? I am thinking of creating a new MeteorJS app and install the angular-meteor package and then start importing my AngularJS modules from existing project. Is this the best approach? Can you share some tips or best practices?

Rami Enbashi
  • 3,526
  • 1
  • 19
  • 21
  • I think I would approach this by thinking about what you'd like to replace out of your mean stack. I would assume you'd want to get rid of your express portion since mean is mongo, express, angular, and node. Since meteor is mongo and node and you'd like to keep angular, that would leave express. I'm not sure there are any packages that will help you turn an existing mean app into an mman app. Because you'd want to handle the mongo data the "meteor way", it would probably be a rewrite with some help from existing angular templates. – Tim C May 17 '15 at 04:00
  • I migrated several apps from MEAN to meteor. I found it was easiest just to rewrite them, it's surpassingly fast and your code is incredibly clean afterward. – Zargoon May 17 '15 at 05:58

1 Answers1

4

I think that for most use cases, it will be easier to create a new angular-meteor app and port your existing code into that:

  1. Create a new angular-meteor app
  2. Copy your existing Angular code into that app - still work with your old server with $http or whatever service you were using before
  3. Create the data schemes of your old server in the new Meteor server with Collection2 package.
  4. Convert your endpoints and node functions into Meteor methods (almost copy/paste with a few simple changes probably, but can be harder, depends on your implementation)
  5. Replace your Angular $http and communication services with angular-meteor's services

In most cases this would be radically simpler and I think it will be quicker than you think. When I did that to a simple MEAN stack app, the MEAN stack app took 532 Javascript lines and the angular-meteor app took 80 javascript lines, links to the code can be found here: http://info.meteor.com/blog/thoughts-on-angular-meteor-as-a-great-mean-stack

Urigo
  • 3,175
  • 21
  • 27