This is more about REST and Angular's way of working with services than 
anything node specific.  If your service is set up using the canonical REST 
"resource <https://docs.angularjs.org/api/ngResource/service/$resource>" 
pattern then Angular can grok it natively without the need for an explicit 
client module (nor the need for a proxy assuming your DocManager server is 
internet accessible and you have CORS configured properly.  For example 
"List Files" should be

  GET /files/

"Get File Details" should be

   GET /files/some-file

"Update File" should be

   POST /files/some-file

If you follow that pattern then Angular integration is just a one liner 
(this syntax may be a bit out of date, copied from some old code)

  angular.module('myModlule', ['ngResource']).factory('File', 
function($resource) {
      return $resource('http://myserver/files');
   });

If you're not already following that pattern on DocManager then using 
option 2 to map the existing DocManager API into a resource compliant one 
may make sense.  If you are following that pattern and just want to avoid 
CORS issues I'd suggest handling the proxy with something like nginx rather 
than writing any code to do it.

On Tuesday, October 7, 2014 6:44:37 AM UTC-7, dmank wrote:
>
> Hey all,
>
> I'd appreciate some input on a design decision that I'm trying to make.  I 
> have a product that has a fairly robust REST API, with around 100 endpoints 
> and options.  My hope is to setup a Node/Express/Angular stack with modules 
> and libraries on each level to query that REST API, abstracting out the 
> mechanics and specifics of the calls for other developers.  The goal is to 
> have as little code as possible (both for myself and the developers) and 
> keep the configuration fairly basic.
>
> Let me setup an example, lets call the product that hosts REST services 
> "DocManager" and it has hundreds of endpoints - three of which are "List 
> Files", "Get File Details" and "Update File".  I'm struggling with the 
> following options:
>
>    - *Option #1*: Develop a* "docmanager-rest-client"* nodejs module 
>    responsible for wrapping *each *DocManager REST call (List Files, Get 
>    File Details, Update File), rely on the developer to build the routes and 
>    controllers to consume the functions.  No work in Angular.
>    - *Option #2*: Develop a *"docmanager-rest-proxy"* using http-proxy to 
>    proxy/pipe REST requests from DocManager directly to Angular through 
>    nodejs.  All abstraction is done in Angular.
>
> Are these community-acceptable approaches?  Are there any approaches that 
> I'm missing here?  (Authentication is taken care of in either case through 
> custom security)
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/d87b8b3e-2e6d-40af-8fdc-ae7e4a0bd0c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to