mikeal/node.couchapp.js — Issue #34: Support transformations & aggregations of attachments
Author: miccolis
Created: 2011-10-26 17:19:23+00:00
State: open

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](https://github.com/mikeal/node.couchapp.js/issues/14).

I've got the basics working in [my fork](https://github.com/miccolis/node.couchapp.js/tree/attachment_operators) (for push only, not sync) though I'd like to make the API more simple.

```javascript
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.