Open calvinmetcalf opened 10 years ago
I still dream of having this actually work against skimdb. Right now it's not very impressive because it's not working against the main registry; but if it were, it'd be something neat to post to Hacker News to show off what PouchDB can do.
but we could put the couch in our replica of skimdb
Again, I just think it'd be more impressive if it comes directly from skimdb. Also probably would be faster.
Would this work now?
Just checked, but it seems https://skimdb.npmjs.com/registry still doesn't have CORS enabled. @isaacs?
Somebody please tell me exactly what configs to set to enable read access, but no authentication.
$ export HOST=http://username:password@host.com
$ curl -X PUT $HOST/_config/httpd/enable_cors -d '"true"'
$ curl -X PUT $HOST/_config/cors/origins -d '"*"'
$ curl -X PUT $HOST/_config/cors/methods -d '"GET, HEAD"'
$ curl -X PUT $HOST/_config/cors/headers -d \
'"accept, content-type, origin"'
should do it
Right, but does that allow authenticated requests? If I have a session, can someone fetch my _users doc?
that does not allow authenticated requests, you need to set Access-Control-Allow-Credentials: true
for that
nope, you need to have the server configured to respond with
Access-Control-Allow-Credentials: true
with
curl -X PUT $HOST/_config/cors/credentials -d '"true"'
to send any cookies, also the headers is a whitelist so requests with authorization
headers will be rejected
I updated the gh-pages to use the real skimdb, so we'll know when it's working.
So @izs, not sure what the status of this is, but here's an interesting thought:
On one of the NodeUp podcasts you mentioned admiring php.net because their search is crazy fast. I wanted to figure out why, and it turns out it's because they do an ajax request for just south of 1MB worth of json the first time you visit the site, which they immediately jam into localStorage. So by the time your eyeballs have digested the front page, you've already got most of the core APIs loaded locally, and you can type "arr" and immediately see "ArrayAccess", etc.
But npm could potentially do one better, since you could just use PouchDB with filtered replication and store a lot more than 1MB in the local database (e.g. fetch the top 100 packages, then the next 1000, or whatever). Plus you'd get pagination, which localStorage doesn't offer. I've also got a full-text search plugin in the works, but string splitting on whitespace plus map/reduce could probably do you just as well.
So anyway my point is that this crazy little demo app might not be so crazy after all. :) Would be nice to get CORS so we can experiment a bit more.
if we change the url line to be
then we can just stick it in a couchapp and not worry about origin