1 | var routesJson = require('../routes/json.js')
|
2 | , routes = require('../routes/index.js');
|
3 |
|
4 |
|
5 | var path_join = function()
|
6 | {
|
7 | var str = '';
|
8 | for(var i=0; i<arguments.length; i++)
|
9 | {
|
10 | var comp = arguments[i].replace(/^\//,'').replace(/\/$/,'');
|
11 | if(comp == '')
|
12 | continue;
|
13 | str += '/' + comp;
|
14 | }
|
15 | return str;
|
16 | }
|
17 |
|
18 | exports.registerPaths = function(admin,app, root) {
|
19 |
|
20 |
|
21 | routes.setAdmin(admin);
|
22 | routesJson.setAdmin(admin);
|
23 |
|
24 | if (root.length > 1) {
|
25 | app.get(root, routes.index);
|
26 | } else {
|
27 | app.get('/', routes.index);
|
28 | }
|
29 | app.get(path_join(root, '/login'), routes.login);
|
30 | app.get(path_join(root, '/logout'), routes.logout);
|
31 | app.get(path_join(root, '/model/:modelName'), routes.model);
|
32 | app.get(path_join(root, '/model/:modelName/document/:documentId'), routes.document);
|
33 | app.post(path_join(root, '/model/:modelName/document/:documentId'), routes.document_post);
|
34 |
|
35 | app.post(path_join(root, '/json/login'), routesJson.login);
|
36 | app.post(path_join(root, '/json/dependencies'), routesJson.checkDependencies);
|
37 | app.get(path_join(root, '/json/documents'), routesJson.documents);
|
38 | app.post(path_join(root, '/json/model/:collectionName/order'), routesJson.orderDocuments);
|
39 | app.post(path_join(root, '/json/model/:collectionName/action/:actionId'), routesJson.actionDocuments);
|
40 | app.post(path_join(root, '/json/model/:collectionName/document'), routesJson.createDocument);
|
41 | app.put(path_join(root, '/json/model/:collectionName/document'), routesJson.updateDocument);
|
42 | app.delete(path_join(root, '/json/model/:collectionName/document'), routesJson.deleteDocument);
|
43 | app.get(path_join(root, '/json/model/:collectionName/linkedDocumentsList'), routesJson.linkedDocumentsList);
|
44 | }
|