18
votes

I am about to build a web application that shares resources through a Restful API.

It struck me that CouchDB already has a good Restful API layer.

So why would I create my own one.

Couldn't I just let other web applications use my resources (json documents) on CouchDB through it's Restful API directly instead of node.js being the middleman?

Or will I need some logic in between CouchDB and 3rd party web applications?

Haven't yet used CouchDB so I don't know if it's capable of handling advanced authorization and if the "design document javascript" applications are as good as "node.js javascript".

1

1 Answers

17
votes

There are several reason why you want to build your own thin layer in between:

  • non JSON resources (for readable access this might be doable with Couch as well)
  • custom backend logic (i.e. dispatching mails, invoking internal application handlers upon requests)
  • authentication (the auth options for Couch are limited)
  • server-side filtering (might be easier with node.js than an update handler in Couch)
  • security (are you willing to run a couch instance that is directly accessable?)

For myself, I built a RESTful API using CouchDB and node.js. Due to the fact that both use JSON, the necessary overhead is still very small, but you have the full flexibility of your 100% own middle tier code.