Giter Club home page Giter Club logo

node.couchapp.js's Introduction

Installation

Install node.

Install npm.

$ git clone repo
$ cd node.couchapp.js
$ npm install
$ npm link .
$ couchapp help
couchapp -- utility for creating couchapps

Usage - old style with single app.js:
  couchapp <command> app.js http://localhost:5984/dbname [opts]

Usage - new style with multiple app files:
  directory based config specified by switch - multiple app files and pre- and post-processing capability)
  couchapp -dc < <appconfigdirectory> http://localhost:5984/dbname

Commands:
  push   : Push app once to server.
  sync   : Push app then watch local files for changes.
  boiler : Create a boiler project.
  serve  : Serve couchapp from development webserver
            you can specify some options
            -p port  : list on port portNum [default=3000]
            -d dir   : attachments directory [default='attachments']
            -l       : log rewrites to couchdb [default='false']
Directory-based config:

  -dc (directory config) switch uses multiple config files in the directory specified by <appconfigdirectory>

  Any file with a filename that begins with "app" will be executed.

  Additionally

  (i) if the app config directory contains file beforepushsync.js then this will be executed before any of the app files have run
  (ii) if the app config directory contains file afterpushsync.js then this will be executed after all of the app files have run

  beforepushsync.js and afterpushsync.js can be used to perform any before/after processing, using node.js code for example.

  The sample afterpushsync.js shows lookup data being added to CouchDB after the CouchApp has been pushed.

app.js example:

  var couchapp = require('couchapp')
    , path = require('path');

  ddoc = {
      _id: '_design/app'
    , views: {}
    , lists: {}
    , shows: {} 
  }

  module.exports = ddoc;

  ddoc.views.byType = {
    map: function(doc) {
      emit(doc.type, null);
    },
    reduce: '_count'
  }

  ddoc.views.peopleByName = {
    map: function(doc) {
      if(doc.type == 'person') {
        emit(doc.name, null);
      }
    }
  }

  ddoc.lists.people = function(head, req) {
    start({
      headers: {"Content-type": "text/html"}
    });
    send("<ul id='people'>\n");
    while(row = getRow()) {
      send("\t<li class='person name'>" + row.key + "</li>\n");
    }
    send("</ul>\n")
  }

  ddoc.shows.person = function(doc, req) {
    return {
      headers: {"Content-type": "text/html"},
      body: "<h1 id='person' class='name'>" + doc.name + "</h1>\n"
    }
  }
  
  ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {
    function require(field, message) {
      message = message || "Document must have a " + field;
      if (!newDoc[field]) throw({forbidden : message});
    };

    if (newDoc.type == "person") {
      require("name");
    }
  }

  couchapp.loadAttachments(ddoc, path.join(__dirname, '_attachments'));

Local development server example.

Start the server:

couchapp serve app.js http://localhost:5984/example_db -p 3000 -l -d attachments

Now you can access your couchapp at http://localhost:3000/ . Code, hack and when you are happy with the result simply do:

couchapp push app.js http://localhost:5984/example_db

node.couchapp.js's People

Contributors

mikeal avatar zaro avatar philwestwell avatar ajcrites avatar osher avatar isaacs avatar rjcorwin avatar max-mapper avatar christiansmith avatar timjb avatar youdaman avatar stevekrenzel avatar stevekinney avatar sriharshav avatar ryanrolds avatar rmg avatar robertkowalski avatar garbados avatar puls avatar jamescostian avatar derrickoswald avatar dsego avatar drobbins avatar bengl avatar crabdude avatar

Stargazers

Soumik Mukherjee avatar Alloys Mila avatar Cat  avatar mister. jones avatar Szilard avatar Gábor Csárdi avatar Jacob Beard avatar  avatar Evangelos Pappas avatar David Konsumer avatar Matthew Currier avatar  avatar Matt Daniel Brown avatar Dmitry Salnikov avatar Rophy Tsai avatar  avatar Henry Hong avatar  avatar Nelson avatar Patrick de Lanauze avatar Amit Upadhyay avatar H avatar Biniam Bekele avatar Alexander Svyazin avatar Charles Phillips avatar Ritchie Young avatar Maciej Lis avatar Sammy S. avatar Luis G. Gómez avatar Angus H. avatar Mhd Sami Al Mouhtaseb avatar  avatar Matt Schneider avatar Jesse Day avatar Geoff Buesing avatar Reuben Cummings avatar Achim Staebler avatar Iblis Lin avatar  avatar Gabriel Mancini de Campos avatar  avatar Yu-Shih Wang avatar Rafael Jesus avatar nichoth avatar Andrea Parodi avatar Tamlyn Rhodes avatar Ben Smith avatar  avatar Hongbo LU avatar BernadetteM avatar  avatar alirot avatar Bobby Rockers avatar John Mifsud avatar M Haidar Hanif avatar Thiago Cangussu avatar Manan Vaghasiya avatar wesley deglise avatar hhzl avatar Vamsi Krishna B avatar Louis Beltramo avatar Sean Goresht avatar Sparky avatar Iurii Proshchenko avatar Makeev Vitaliy avatar Norman Sue avatar Luke Patterson avatar Phillip Wei avatar Kiko Uehara avatar  avatar  avatar Luis Toscano avatar htc avatar Piyush Chauhan avatar  avatar  avatar charles ross avatar  avatar ig avatar Harald Haesler avatar Nicolas Forgerit avatar Shawn Jonnet avatar Nick Barth avatar  avatar Jelle Akkerman avatar Jordan Skole avatar mgb avatar mhouston avatar Jānis avatar deJaVisions avatar Kolin Weidmann avatar Andrew Appleton avatar  avatar Luke Kreczko avatar  avatar Peter Vinum avatar Petter Aas avatar Brett Whitty avatar saighost avatar Patricio Valarezo  avatar

Watchers

 avatar Andriy Tyurnikov avatar Wlodek Bzyl avatar Gabriel de Oliveira Barbosa avatar  avatar Torsten Ek avatar Nicolas Forgerit avatar Stephan H. Wissel avatar 小爪哇 avatar William Xue avatar James Cloos avatar Kelsey Dawes avatar Dan Ross avatar  avatar  avatar  avatar  avatar Jason Doiron avatar  avatar

node.couchapp.js's Issues

Cannot find module error

I received a Cannot find module error when trying to use couchapp on Windows XP. I'm not sure whether this is an npm issue or whether it is node couchapp. I'm running node version 0.6.13 and npm version 1.1.9.

git clone https://github.com/mikeal/node.couchapp.js.git
cd node.couchapp.js

installed couchapp globally:

npm install -g

and installed couchapp locally:

cd ..
cd test
npm install ".\..\node.couchapp.js"

Then I created the most basic app.js file:

var couchapp = require('couchapp')
var ddoc = {_id:'_design/app', shows:{}, updates:{}, views:{}, lists:{}};
exports.app = ddoc;

And tried running

node couchapp <command> app.js http://address.to.couch/database

but unfortunately it failed to work for me. I received the following error:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: Cannot find module '<path_to_directory>\test\couchapp'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Array.0 (module.js:479:10)
    at EventEmitter._tickCallback (node.js:192:40)

Instead I managed to get it working with the following:

node "./node_modules/couchapp/bin.js" push app.js http://address.to.couch/database

WindowsXP - couchapp boiler - returns a falsy error notice

WindowsXP SP3, node 6.9, couchapp 0.9.1

Trying to create apps using the boiler, I get:


D:\couchapps>couchapp boiler test
Could not create D:\couchapps\test

D:\couchapps>couchapp boiler testss
Could not create D:\couchapps\testss

D:\couchapps>

I thought maybe I already have a test folder, so I tried again with testss
Suprizingly, in fact, both project were created with Trees as following:

D:couchapps\test
│   app.js
│
└───attachments
    │   index.html
    │   jquery-1.4.4.min.js
    │   layout.css
    │   site.js
    │
    └───sammy
        │   sammy.js
        │
        └───plugins
                sammy.cache.js
                sammy.data_location_proxy.js
                sammy.ejs.js
                sammy.form.js
                sammy.haml.js
                sammy.json.js
                sammy.meld.js
                sammy.mustache.js
                sammy.nested_params.js
                sammy.path_location_proxy.js
                sammy.pure.js
                sammy.storage.js
                sammy.template.js
                sammy.title.js

I'll look at it later and see if I can find the cause and submit a Pull-Request.

Error on push: Cannot find module 'couchapp'

nick@bigdaddy3:/workspace/mi6$ ls
app.js attachments
nick@bigdaddy3:
/workspace/mi6$ curl http://localhost:5984/mi6
{"db_name":"mi6","doc_count":0,"doc_del_count":0,"update_seq":0,"purge_seq":0,"compact_running":false,"disk_size":79,"instance_start_time":"1316825332528937","disk_format_version":5,"committed_update_seq":0}
nick@bigdaddy3:~/workspace/mi6$ couchapp push app.js http://localhost:5984/mi6

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'couchapp'
at Function._resolveFilename (module.js:326:11)
at Function._load (module.js:271:25)
at require (module.js:355:19)
at Object. (/home/nick/workspace/mi6/app.js:1:79)
at Module._compile (module.js:411:26)
at Object..js (module.js:417:10)
at Module.load (module.js:343:31)
at Function._load (module.js:302:12)
at require (module.js:355:19)
at Object. (/usr/local/lib/node_modules/couchapp/bin.js:78:24)

Bad Global Install - couchapp misbehaving fresh out of the box

It looks like some of my dependencies are messed up for couchapp, and I assume this is causing the slew of errors that are preventing me from getting this up and running.

I've run

Keith$ npm --version
1.1.59

and I've run npm update - 1.1.59 is the newest version. Any ideas about how I can meet these dependencies? Thanks!

EDIT: I changed "mime" : "1.2.2" to "mime" : "*" and cleared dependency issue, but I am not savvy enough to know the repercussions of this - not sure if this is a fair solution.

Keith$ npm -g ls
npm WARN unmet dependency /usr/local/lib/node_modules/couchapp/node_modules/request/node_modules/form-data requires mime@'1.2.2' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/couchapp/node_modules/request/node_modules/mime,
npm WARN unmet dependency which is version 1.2.7
/usr/local/lib
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected] extraneous
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected] invalid extraneous
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Windows XP - couchapp sync - throws error

Hi,
I tried today for the first time to work in Sync mode, however, ran into the following exception:

D:\ws\OSGE\1000\sources\node_dev\STP\node_modules\serial>couchapp sync svr-app.js http://stpuser:secretpassword@localhost:5984/stp
The "sys" module is now called "util". It should have a similar interface.
Preparing.
Serializing.
PUT http://stpuser:******@localhost:5984/stp/_design/serial-killer
Finished push. 8-9a9e67bf58e61786eb25ed7d220b844c

Watching files for changes...

fs.js:734
    throw new Error('use fs.watch api instead');
          ^
Error: use fs.watch api instead
    at Object.watchFile (fs.js:734:11)
    at C:\Documents and Settings\osher\Application Data\npm\node_modules\couchapp\node_modules\watch\main.js:56:10
    at C:\Documents and Settings\osher\Application Data\npm\node_modules\couchapp\node_modules\watch\main.js:83:5
    at Object.oncomplete (C:\Documents and Settings\osher\Application Data\npm\node_modules\couchapp\node_modules\watch\main.js:42:39)

I'm using WinXP sp3, node 0.6.9,
couchapp version : 0.9.0

example bug

couchapp.loadAttachments(ddoc, path.join(__dirname, '_attachments'));

should be

couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments'));

also, it would be nice to have the urls required to show us what the example code does.

how to reuse code in node.couchapp?

I want to do something like this (or import external files and use functions in them).

 var couchapp = require('couchapp')
, path = require('path')
;

ddoc =
{ id:'design/app'
, rewrites :
[ {from:"/", to:'index.html'}
, {from:"/api", to:'../../'}
, {from:"/api/
", to:'../../
'}
, {from:"/", to:''}
]
};

ddoc.views = {};
transactionDate = function(doc){
date_to_array = function(date){
return [date.getFullYear(),
(date.getMonth() + 1),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds()];
};
return date_to_array(new Date(doc.time.end));
};

ddoc.views.transactions_by_type = {
map : function (doc) {

const transaction_type = doc.type;
var key = ([transaction_type])
/*  key = key.concat(doc.store.chain);
 key = key.concat(doc.store.store_id);
 key = key.concat(doc.terminal_id);*/
    .concat(transactionDate(doc));
emit(key, 1);
},
reduce: "_sum"

};

currently, this doens't work. I've tried variations and can't get anything to work. I've been told by people on #couchdb that reusing code in node.couchapp is possible.

Executable does not work when not installed globally

Running this node_modules/.bin/couchapp, generates:

module.js:340
    throw err;
          ^
Error: Cannot find module './main.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/cyberfunk/git/clients/socialally/sa-registry/node_modules/.bin/couchapp:3:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Because npm adds node_modules/.bin to PATH when executing scripts then it will not work in scripts that just want to reference couchapp for a locally installed version.

This is easily fixed with backward compatbility, if you will accept a pull request I will patch it.

sync issue mac os x

using "sync", changing/editing existing files (e.g. app.js) doesn't appear to be detected and changes were not sync. I am using mac os x using node 0.4.0. Issue with watch? (maybe)

Authentication

It'd be nice for Couchapp to provide authentication (so that it can be used for production servers where authentication is used). There are different ways this could be done (use .netrc, use standard URL-encoded http://login:password@.../ , etc.).

FWIW I've implemented a simplistic solution in https://gist.github.com/840501 (the Base64-encoded string found after "Authorization: Basic" is provided as an optional argument), although a nicer scheme is probably preferable.

ENOTFOUND on push over VPN

When pushing to a server connected to via a VPN tunnel, node.couchapp fails with:

Error: ENOTFOUND, Domain name not found
at IOWatcher.callback (dns.js:74:15)

let it work behind a proxy

I cannot reach the remote server directly from my network and need to go through a proxy.

It appears request/main.js has support for proxy, but I've not managed to make it work without a patch.

One way would be to pass proxy in options, and let it specify in command line arguments, but I found it better to let request/main.js use http_proxy/https_proxy enviroment variable:

Index: node_modules/couchapp/node_modules/request/main.js

--- node_modules/couchapp/node_modules/request/main.js (revision 117)
+++ node_modules/couchapp/node_modules/request/main.js (working copy)
@@ -104,6 +104,10 @@
if (options.proxy) {
if (typeof options.proxy == 'string') options.proxy = url.parse(options.proxy)
}

  • var v = {"http:":'http_proxy', "https:":'https_proxy'}[options.uri.protocol];
  • if (!options.proxy && process.env[v]) {
  • options.proxy = url.parse(process.env[v])
  • }

options._redirectsFollowed = options._redirectsFollowed || 0
options.maxRedirects = (options.maxRedirects !== undefined) ? options.maxRedirects : 10

Hope you'll find it useful, or please let me know if there is better solution.

TODO: mention this in documentation.

Thank you.

pulling from npm gives errors

paul@paul-rt7-desktop:~$ couchapp -h

node.js:197
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: The "sys" module is now called "util".
    at sys.js:1:69
    at NativeModule.compile (node.js:517:5)
    at Function.require (node.js:485:18)
    at Function._load (module.js:296:25)
    at Module.require (module.js:356:17)
    at require (module.js:372:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/couchapp/main.js:2:11)
    at Module._compile (module.js:443:26)
    at Object..js (module.js:461:10)
    at Module.load (module.js:350:32)

node.couchapp is installed and runs, but node.js can't find couchapp module

Using version ec5852c (April 28, 2011), I have node.couchapp installed and it runs:

$ couchapp
couchapp -- utility for creating couchapps

Usage:
couchapp app.js http://localhost:5984/dbname

Commands:
push : Push app once to server.
sync : Push app then watch local files for changes.
boiler : Create a boiler project.
$

but when doing a push, node.js cannot find the 'couchapp' module:

$ couchapp push app.js http://localhost:5984/noca0

node.js:181
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'couchapp'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:364:19)
at Object. (/Users/luciano/prj/ramgarlic/gcode/js/couch/node.couchapp/app.js:1:78)
at Module._compile (module.js:420:26)
at Object..js (module.js:426:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at require (module.js:364:19)
at Object. (/Users/luciano/opt/node.couchapp.js/bin.js:68:22)
$

Please, update npmjs.org with version 0.10.1

Today is 0.10.0 version:
https://registry.npmjs.org/couchapp

"time": {
"0.2.0": "2011-01-04T01:24:31.102Z",
"0.5.0": "2011-01-04T01:24:31.102Z",
"0.5.1": "2011-01-04T01:24:31.102Z",
"0.7.0": "2011-01-04T01:24:31.102Z",
"0.8.0": "2011-02-19T00:00:43.650Z",
"0.8.1": "2011-08-10T18:26:21.853Z",
"0.9.0": "2011-12-09T17:51:34.384Z",
"0.9.1": "2012-06-26T21:16:21.117Z",
"0.10.0": "2013-06-23T22:44:11.957Z"
}

Cannot safely push multiple times

I use code like the following (CoffeeScript):

couchapp = require 'couchapp'
for script in ['authorize','replicate','global']
  couchapp.createApp require("./#{script}"), uri, (app)-> app.push()

in order to push multiple design documents at once,

However this does not work because couchapp shares the "headers" parameter (var h) between multiple request() instances.

(The issue happens whether the push() operations are in parallel (my example above) or serialized.)

Fix: copy line 11 in main.js so that each request(...) call gets its own, independent set of headers.

error trying to push a couchapp

I was pushing couchapps earlier, just fine. now i get this error and i don't understand it.


$~/Dropbox/work/rt7/graphing$ curl -X PUT http://localhost:5984/graphing
{"ok":true}

$~/Dropbox/work/rt7/graphing$ couchapp push http://localhost:5984/graphing

node.js:205
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '/home/paul/Dropbox/work/rt7/graphing/http:/localhost:5984/graphing'
at Function._resolveFilename (module.js:318:11)
at Function._load (module.js:263:25)
at Module.require (module.js:341:17)
at require (module.js:352:17)
at Object. (/home/paul/local/lib/node_modules/couchapp/bin.js:78:24)
at Module._compile (module.js:416:26)
at Object..js (module.js:434:10)
at Module.load (module.js:335:31)
at Function._load (module.js:294:12)
at Array. (module.js:454:10)

license missing

Sorry that I am nitpicking here, but for some usages of couchapp.js a license is really important.

Can we add one? I can prepare a PR if you name me the desired one.

-dc does not support `serve`

Currently trying to use -dc with serve will just have couchapp exit quietly. It seems to work by just adding

else if (command == 'serve') {
  serve(app);
}

after line 164, but I'm not sure if this omission is intentional.

can't push to server when username and/or password have spaces in them

example

couchapp push app.js http://my name:my password@localhost:5984/mydb


The "sys" module is now called "util". It should have a similar interface.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: getaddrinfo ENOENT
    at errnoException (dns.js:31:11)
    at Object.onanswer [as oncomplete] (dns.js:140:16)

Preparing.

Hi

I have from time to time, and I really don't know what is causing it, the fact that pushing or syncing my couchapp with couchDB returns simply "preparing." "After a while" (read: I just don't know what is happening) I can push or sync again.

I can see that couchDB receives a request and returns code 404 (The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. )

If I manually create a document with ID _design/app couchDB returns code 200, but couchapp is still returning Preparing.

edit: found the issue
After some more investigation I found out that couchapp stops uploading when I have an empty folder in my "attachments" folder.

Could not push document containing UTF-8 characters

Hi!

Given the file app.js:

var couchapp = require('couchapp');
var ddoc = {
  _id:'_design/app',
  shows: {}
};
ddoc.shows.foo = function (doc, req) {
  return "ąćęłńóśźż ĄĆĘŁŃÓŚŹŻ";
};
module.exports = ddoc;

the command:

couchapp push app.js http://localhost:5984/utf8

produces:

Preparing.
Serializing.
PUT http://localhost:5984/utf8/_design/app

~/github.com/node.couchapp.js/main.js:68
      if (resp.statusCode !== 201) throw new Error("Could not push document\n"
                                         ^
Error: Could not push document
{"error":"bad_request","reason":"invalid UTF-8 JSON:  <<123,34,95,105,100,34,58,34,95,100,101,115,105,103,110,47,\n
...

I'm using node and node.couchapp.js from the github repos.

Regards

--Włodek Bzyl

Support transformations & aggregations of attachments

The idea here would be to allow a couch app to provide it's own functions to transform and/or aggregate various attachment files. This would enable you to do things like transform templates into javascript and aggregate them together to be served as a single file to a browser.

This is a more general case of using uglify to minimize attachments.

I've got the basics working in my fork (for push only, not sync) though I'd like to make the API more simple.

couchapp.loadAttachments(ddoc, path.join(__dirname, 'templates'), {
   operators: [function(f, data) {
     var content = data.toString('utf8'));
     // Do something...
     return new Buffer(content);
   }],
   aggregator: function(files) {
      // `files` is an array of objects..
      // e.g. [{data: '', name: '', mime: ''}]
      // Return aggregated version of this array.
   return files;
 });

My question here is basically whether this is something that would be considered for inclusion. If so whether this sort of API looks reasonable.

Change from exports.app = ddoc to module.exports = ddoc

Was getting the following error until I smartened up and looked at your test case and emulated it:

Trying to use exports.app = ddoc no longer works use module.exports = ddoc instead.

The following was the error I was getting:

node.js:50
    throw e; // process.nextTick error, or 'error' event on first tick
    ^
TypeError: Cannot read property 'length' of undefined
    at Object.createApp (/usr/local/lib/node/.npm/couchapp/0.7.0-1-LINK-ed99324a/package/main.js:203:37)
....

Hopefully this helps someone else.

Couchapp adds %5C to the start of every file

After creating a new couchapp boiler, and pushing it to the server, I kept getting "file not found" errors.

I figured (and still do) that this is a virgin couch problem.. but I was able to sort out that the reason why the files were not found was because there was an escaped HTML "" in the filename.

so if I typed in host:5984\myapp_design\myapp\index.html // file not founderror

http://dev.thumperdaffodil.com/couch/2.jpg

if I added a %5c to the url, I'd get the file

host:5984\myapp_design\myapp%5cindex.html // works

http://dev.thumperdaffodil.com/couch/1.jpg

I'm using the latest version of Node (0.6.7) and the most recent version of Couchapp (0.9.0) and CouchDB version 1.1.1

Any thoughts?

Add attachment by name (rather than through directory)

As far as I can tell, it is currently impossible to add a file -- not a directory -- to the design doc. Something like this:

couchapp.loadFile(ddoc, './index.html');

This feature is especially important to turning other projects into couchapps, where it's inconvenient / unsustainable to move stuff around in order to fit a couchapp's idea of directory structure.

couchapp boiler - Could not create...

The boiler option doesn't exit cleanly for me.

I installed couchapp using npm.

prince$ npm view couchapp | grep dist-tags
  'dist-tags': { latest: '0.9.0' },
prince$ mkdir recruit
prince$ cd recruit
prince$ couchapp boiler
The "sys" module is now called "util". It should have a similar interface.
Could not create /Users/martin/dev/recruit

However despite the error message it has created something.

prince$ find . -type f
./app.js
./attachments/index.html
./attachments/jquery-1.4.4.min.js
./attachments/layout.css
./attachments/sammy/plugins/sammy.cache.js
./attachments/sammy/plugins/sammy.data_location_proxy.js
./attachments/sammy/plugins/sammy.ejs.js
./attachments/sammy/plugins/sammy.form.js
./attachments/sammy/plugins/sammy.haml.js
./attachments/sammy/plugins/sammy.json.js
./attachments/sammy/plugins/sammy.meld.js
./attachments/sammy/plugins/sammy.mustache.js
./attachments/sammy/plugins/sammy.nested_params.js
./attachments/sammy/plugins/sammy.path_location_proxy.js
./attachments/sammy/plugins/sammy.pure.js
./attachments/sammy/plugins/sammy.storage.js
./attachments/sammy/plugins/sammy.template.js
./attachments/sammy/plugins/sammy.title.js
./attachments/sammy/sammy.js
./attachments/site.js

Authentication: handle % in username and password

This is a follow-up to #7. I had assumed too fast that authentication was missing because of my dataset. Actually the issue is related to non-standard characters showing up in the username (and/or password, I would assume). These are normally URL-encoded inside a URL, so for example username "[email protected]" with password "bobpass" will become 'http://bob%40example.org:[email protected]:5984/database' on the command line.

When submitting to CouchDB, the Basic Authentication string should be built from the URL-decoded string: "[email protected]:bobpass". However when I do a trace between node.couchapp.js and CouchDB in this example, I see that the Basic authentication token uses the original string "bob%40example.org:bobpass" instead.

README.md - intstall from NPM

Dear friend, I'm using couchapp for 3 years now, and love it.

I think after so long the project is mature enough to replace the installation section in the README.md to

npm install couchapp -g

And if you really want to be nice you can give a disclaimer for windows users, their npm generated cmd files and the PATH they should assure configured.

:)

Percent character in password causes lookup error

Using node 0.4.7, couchapp 0.8.0, request 2.1.1, and my CouchDB user's password looks something like this: %1AzsSJSx3faaj3 which leads to this error when attempting to push:

couchapp push app.js "http://dhuser:%[email protected]:5984/downhill"

/usr/local/lib/node_modules/couchapp/main.js:297
    if (err) throw err;
             ^
Error: ENOTFOUND, Domain name not found
    at IOWatcher.callback (dns.js:74:15)

node 7.6 release problem: Error: The "sys" module is now called "util".

paul@paul-rt7-desktop:~/Dropbox/work/rt7/db/users$ couchapp push filters.js http://paul:password@localhost:5984/_users

node.js:197
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: The "sys" module is now called "util".
    at sys.js:1:69
    at NativeModule.compile (node.js:517:5)
    at Function.require (node.js:485:18)
    at Function._load (module.js:296:25)
    at Module.require (module.js:356:17)
    at require (module.js:372:17)
    at Object.<anonymous> (/home/paul/node_modules/couchapp/main.js:2:11)
    at Module._compile (module.js:443:26)
    at Object..js (module.js:461:10)
    at Module.load (module.js:350:32)

Add command "get" or "pull"

Will be very useful to construct a folder-structure from an existing source document

A nice to have is to support both a live document in a couch-db, or a file that is an export file of an entire document with all the attachments (like the format the original python tool creates).

If it is supported and my bad could not find it - just update the docs :-)

Debian Sid Issues

To get this to work under debian sid, I needed to do a few things that aren't included in the documentation for couchapp et al:

  1. cd /usr/bin ; ln nodejs node

  2. export NODE_PATH=/usr/local/lib/node_modules

  3. ulimit 10000 even though ulimit said "unlimited".

  4. add a bunch of types in /usr/local/lib/node_modules/couchapp/mimetypes.js

I think the ulimit problem may be viewed as a bug in couchdb if not Erlang itself, since Erlang's aggressive parallelism really should be paying attention to the ulimit in the core.

Watch for changes in design document

As far as I can tell from the code all the attachements are worked through and then watched for changes (this sync works excellent BTW). I'd love to have this extended to the greatfile.js I pass over essentially as design document...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.