forked from open211/redirectory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (32 loc) · 1.21 KB
/
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
var couchapp = require('couchapp')
, path = require('path')
;
ddoc =
{ "_id":"_design/app"
, "rewrites" :
[ {"from":"/", "to":"index.html"}
, {"from":"/api/search", "to":"../../../_search/social_services/social_services/_search"} // github.com/tilgovi/redirectory/wiki/Installation
, {"from":"/api/social_services", "to":"../../../social_services"}
, {"from":"/api/social_services/geo", "to":"../../../social_services/_design/geo/_spatial/latlon"} // github/maxogden/geocouch-utils
, {"from":"/api/social_services/*", "to":"../../../social_services/*"}
, {"from":"/api/cities", "to": "_spatial/cities", "query" : {"bbox": "-180,-90,180,90"}}
, {"from":"/api", "to":"../../"}
, {"from":"/api/*", "to":"../../*"}
, {"from":"/*", "to":"*"}
]
}
;
ddoc.spatial = {
cities: function(doc) {
if(doc.name && doc.geometry && doc.type == "city") {
emit(doc.geometry, doc);
}
}
}
ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {
if (oldDoc && userCtx.roles.indexOf('_admin') === -1) {
throw "Only admin can modify documents on this database.";
}
};
couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments'));
module.exports = ddoc;