Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB as the Restful API layer?

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".

like image 603
ajsie Avatar asked Nov 01 '10 18:11

ajsie


People also ask

Which is a CouchDB API?

The CouchDB database has a REST API which allows you to work with the database's JSON documents. With this API, you can create your own requests right in ReadyAPI to work with JSON documents inside the database and get the necessary data from the CouchDB server.

Is REST application layer?

REST is an API (Application Programming Interface) in the Application Layer.

What is REST API in Javascript?

A REST API is a way of easily accessing web services. When a RESTful API is called, the server will transfer to the client a representation of the state of the requested resource.


1 Answers

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.

like image 58
b_erb Avatar answered Sep 20 '22 20:09

b_erb