Skip to content
This repository

HTTP support for node.js #175

Closed
daleharvey opened this Issue October 23, 2012 · 14 comments

4 participants

Dale  Harvey Nick Thompson John Chesley Randall Leeds
Dale  Harvey
Owner

This should be a simple matter of mapping http to pouch calls, and will let us replicate from idb to node

John Chesley

Guessing this isn't referring to the http client, but rather a server mapping HTTP requests to pouch calls?

Dale  Harvey
Owner

Yup, so the http client could talk to a node instance on a server

John Chesley

Interesting, I hadn't thought of using it that way. Figured if you need a server, just use Couch. What would the API for running that server look like?

Pouch("ldb://mydb").createServer().listen(host, port)

Or would it be a command-line tool:

$ pouchserver ldb://mydb

...or both/neither?

Dale  Harvey
Owner

I tend to make my modules both consumed by CL and by other modules, a lot of people have asked to be able to use pouch as a mini couch replacement to get up and running, but as you said if you want a server then couchdb is there so this is really low down on the list of things to get done

Dale  Harvey
Owner

Chris Anderson mentioned another really good reason to do this, CouchDB has a huge extensive test suite that runs against a running couchdb, with a http adapter we could run it against PouchDB

John Chesley

That's a good point. I think it would be a good idea to create a separate project/module for this, to keep server-specific code and dependencies out of the main pouchdb project.

Dale  Harvey
Owner

So @tilgovi took about the craziest approach for this and used emscripten to compile nodes http / net libraries in javascript so he could build a server on top of chromes tcp socket library

An awesome part about this craziness is we can write a single simple http library that works in both the browser and on the server.

@tilgovi any chance you can point people to the right repo's and the basic steps to get your plugin up and running?

Nick Thompson

Hey all,

I started working on this here. It's pretty early on, but currently it satisfies something like the first 40 http tests from the pouch test suite and I hope to have many more than that by the end of the day. You can use it directly as a drop-in replacement for couch, by which I mean if you shut off our local couch server and spin this node instance up on port 5984, you can run the pouch test suite verbatim.

If you have suggestions or feedback or anything, please let me know! I'm more than happy to adapt my implementation to fit the right needs.

Dale  Harvey
Owner

This is perfect, thanks

One thing is, your uuid implementation is nice but the fact you had to do it shows a gap in our implementation, its a tricky gap since the best API for these type of global resources is tricky, but thats one of the reasons for doing this.

So I would keep it as is and work on the implementation to get the test passing, but make a note, maybe file an issue that we need to replace that implementation with one that works on pouch plain

Dale  Harvey
Owner

Hey Nick

So a bunch of people want to test this out, I prefer to keep the person writing the code to publish it since it just makes it obvious who / where to go to, if you would be able to publish it on npm that would be awesome, its really easy to get that working

https://npmjs.org/doc/developers.html

Nick Thompson

Moar updates, w00t.

I've renamed the repository from "pouch-server" to "pouchdb-server", so existing links that you may find around this subject will likely be broken; here's a valid link: https://github.com/nick-thompson/pouchdb-server.

The package is now published to npm, and can be installed with npm install pouchdb-server, but read the documentation in the README linked above before you jump into that; there's an alternative install method that's preferred if you intend to run the test suites.

As of now, pouchdb-server passes the full PouchDB test suite, both via node and the browser. Next steps include maintaining that status as well as porting the CouchDB server over for more extensive testing.

Suggestions/feedback welcome, as always!

Randall Leeds
Nick Thompson

Awesome, that'll be really cool to play with. I don't know much about how the chrome app server is structured, but if you think it'd be a clean integration into pouchdb-server, then I'd be happy to accept a PR!

Dale  Harvey
Owner

I think we are good to close this now :D awesome job

Dale  Harvey daleharvey closed this March 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.