What are the best-practices in order to re-use/share code between an AngularJS client and a Node.js server?
I implemented an AngularJS application. Now I need to implement a RESTful-server providing the client with data. Some client-side angular services could be re-used on server, as for example third-party restful-clients to Facebook/Google/Twitter, which use intensively the angular dependency injection and which are dependent on $http
, $q
and many other services.
Ideally, as I really like the dependency injection framework included in AngularJS, I would find very nice to have a kind of server-framework based on AngularJS. A server-framework that includes the dependency injection framework and all angular-services that are not related to UI, and adding required server-side functionality like routing and authentication. But unfortunately, I didn't find any solution going that way. (Please tell me if such a framework exists!)
So, what would be an alternative, in order to at least enable code re-use between the client and the server? Particularly enabling code re-use for code depending on $http
, $q
and other AngularJS services included in the angular framework and angular-third-parties (like angular-cache
).