-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
executable file
·40 lines (35 loc) · 1014 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var couchapp = require('couchapp')
, path = require('path')
;
ddoc =
{ _id:'_design/ftang'
, rewrites :
[ {from:"/", to:'index.html'}
, {from: "/iphone", to:'iphone.html'}
, {from: "/play.gif", to:'img/play.gif'}
, {from:"/api/artists", to:'_view/artists', query: {"group": "true"}}
, {from:"/api/artist/:artist", to:"_view/artist", query:{startkey:":artist", endkey:":artist", include_docs: "true"}}
, {from:"/api", to:'../../'}
, {from:"/api/*", to:'../../*'}
, {from:"/*", to:'*'}
]
}
;
ddoc.views = {
artists: {
map: function(doc) {
if (doc.artist) emit(doc.artist, 1);
},
reduce: "_sum"
},
artist: {
map: function(doc) {
if (doc.artist) emit(doc.artist);
}
}
}
ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {
if (userCtx.roles.indexOf('_admin') === -1) throw "Only admin can do stuff on this database.";
};
couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments'));
module.exports = ddoc;