Accessing Couchbase instance via Javascript (not Node.js) - javascript

I am looking to be able to access a Couchbase instance via Javascript. My intent is to use Couchbase as the backend for a Qooxdoo JSON datastore. I understand that Couchbase has a RESTful interface but, eventually, I'll need to wrap security and some other functions, so I'm guessing that a direct connection will not meet my requirements.
So, my question is, what would be the best way to do this? Sounds like a proxy server built around an existing Couchbase client is the way to go, but I'm open to suggestions. I'm looking for light-weight and fast.
Thanks!

There is nginx module built which allows to access couchbase over HTTP http://labs.couchbase.com/couchbase-nginx-module/
So you can expose your storage and use authentication schemes provided by other nginx modules.
Oh, and also there is REST wrapper written in ruby https://github.com/couchbaselabs/couchbase-rest-api-rails

Related

Call Bokeh Server App Python Function from Javascript

I am searching for a way to call a python function of my Bokeh Server App from arbitrary Javascript. I want to write custom widgets using HTML/Javascript only and use them to interact with the Bokeh App. I know that one can extend bokeh. Is this is the only way to go? For fast prototyping I think it would be nice to just use the websocket connection to send requests to the app, something along this line:
Bokeh.call('my_python_func', arg1, arg2)
As of Bokeh 0.13.0 this capability does not yet exist directly in the library. You can follow the GitHub issue #5983 Events with feedback / Simple RPC to get updates about any ongoing development.
Otherwise, any alternatives are somewhat involved. If the Python you would like to call is available behind some REST API you could certainly invoke that from JS using standard means.

Qooxdoo tested json rpc javascript websocket client

I'm starting a new project and I'm using qooxdoo js framework.
I'm running against a json rpc 2.0 server based on websocket communication.
I wonder if there's already a tested json rpc client for qooxdoo or should I pick any implementation like jayson.
Any considerations to take?
i think it's always better to exclude the server communication to the lowest possible layer so you are not dependent on frameworks in case of changes.
We have our communication written in plain javascript.
Regards,
Mark

Connecting DB with my Firefox OS app using JS

I'm developing an app for Firefox OS and I need to retrieve/sent data from/to my DB. I also need to use this data in my logic implementation which is in JS.
I've been told that I cannot implement PHP in Firefox OS, so is there any other way to retrieve the data and use it?
PS: This is my first app that I'm developing, so my programming skills are kind of rough.
You can use a local database in JS, e.g. PouchDB, TaffyDB, PersistenceJS, LokiJS or jStorage.
You can also save data to a backend server e.g. Parse or Firebase, using their APIs.
Or you can deploy your own backend storage and save data to it using REST.
You should hold on the basic communication paradigms when sending/receiving data from/to a DB. In your case you need to pass data to a DB via web and application.
Never, ever let an app communicate with your DB directly!
So what you need to do first is to implement a wrapper application to give controlled access to your DB. Thats for example often done in PHP. Your PHP application then offers the interfaces by which external applications (like your FFOS app) can communicate with the DB.
Since this goes to very basic programming knowledge, please give an idea of how much you know about programming at all. I then consider offering further details.
It might be a bit harder to do than you expect but it can be easier than you think. Using mysql as a backend has serious implication. For example, mysql doesn't provide any http interfaces as far as I know. In other words, for most SQL based databases, you'll have to use some kind of middleware to connect your application to the database.
Usually the middleware is a server that publish some kind of http api probably in a rest way or even rpc such as JSONrpc. The language in which you'll write the middleware doesn't really matter. The serious problem you'll face with such variant is to restrict data. Prevent other users to access data to which they shouldn't have access.
There is also an other variant, I'd say if you want to have a database + synchronization on the server. CouchDB + PouchDB gives you that for free. I mean it's really easy to setup but you'll have to redesign some part of your application. If your application does a lot of data changes it might end up filling your disks but if you're just starting, it's possible that this setup will be more than enough.

Create DDP Server using Node.js

Due to restrictions on node.js versions, recent versions of Meteor cannot be used on the system. A DDP server has to be created using regular node.js instead, which a Meteor setup will connect to.
DDP client can be created in node.js using node-ddp-client, but how can we create a DDP server?
It might be too late to answer this and this might not be a good answer anyway. It's not an easy task, we need to manage sessions, users, methods, publications... As a reference for a brave developer :)
We need EJSON or some other implementation to serialize and deserialize messages between client and server.
We need a socket server (sockjs would be a good choice since meteor is using it too.)
We need to implement DDP specification
I've found https://www.npmjs.com/package/ddp-server-reactive and https://www.npmjs.com/package/ddp-server which both seem to do the job

CouchDB AJAX interaction

I'm writing a CouchDB sample. My intention is to write a web app using AJAX and deploy it in the tomcat environment. As I use the CouchDB I would like to know the way to interact with the CouchDB server. However there were few examples but I have few concerns over that.
1) As my application is deployed in a web server is it possible to connect with a CouchDB outside? Many examples uses apps which are deployed in CouchApp or Couch environment itself.
2) If so will it end up with cross domain issues. I found this in here
Connection AJAX, CouchDB and JavaScript
However will this be a problem? Is this the correct way to achieve this?
3) To omit above issues is it possible to use some server side javascript implementation as an example Rhino?
http://www.mozilla.org/rhino/doc.html
4) If I use Rhino above it wont allow many java script libraries to use. How do I interact with CouchDB then? Do I have to invoke native Javascript? Cant I use something like JQuery?
5) What are the best libraries for client side to achieve my goal?
Your help is appreciated.
Thank you
Based on your need to use tomcat, I would just recommend using ektorp (http://ektorp.org/). Just think of ektorp like a jdbc driver. No need to do ajax from the user interface, or no need to use javascript from java in your server.
Ektorp also lets you annotate your java classes with the javascript couchdb needs to make views. see the example here: http://ektorp.org/reference_documentation.html#d100e753
Hope that helps.

Categories