mirror of
https://github.com/documize/community.git
synced 2025-08-08 06:55:28 +02:00
WIP Converting routes to use factories
This commit is contained in:
parent
ac9b749dd2
commit
41fd9b68a2
1 changed files with 97 additions and 137 deletions
|
@ -17,7 +17,6 @@ export default function() {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
this.get('/public/meta', function(db) {
|
this.get('/public/meta', function(db) {
|
||||||
console.log(db.meta[0]);
|
|
||||||
return db.meta[0];
|
return db.meta[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -125,54 +124,27 @@ export default function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders', function() {
|
this.get('/folders', function(db) {
|
||||||
return [{
|
return db.folders;
|
||||||
"id": "VzMuyEw_3WqiafcG",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"name": "My Project",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"folderType": 2
|
|
||||||
}, {
|
|
||||||
"id": "VzMygEw_3WrtFzto",
|
|
||||||
"created": "2016-05-11T13:24:17Z",
|
|
||||||
"revised": "2016-05-11T13:25:51Z",
|
|
||||||
"name": "Test",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"folderType": 1
|
|
||||||
}];
|
|
||||||
// return [
|
|
||||||
// {
|
|
||||||
// "id":"VzMuyEw_3WqiafcG",
|
|
||||||
// "created":"2016-05-11T15:08:24Z",
|
|
||||||
// "revised":"2016-05-11T15:08:24Z",
|
|
||||||
// "name":"My Project",
|
|
||||||
// "orgId":"VzMuyEw_3WqiafcD",
|
|
||||||
// "userId":"VzMuyEw_3WqiafcE",
|
|
||||||
// "folderType":2
|
|
||||||
// },{
|
|
||||||
// "id":"VzMygEw_3WrtFzto",
|
|
||||||
// "created":"2016-05-11T13:24:17Z",
|
|
||||||
// "revised":"2016-05-11T13:25:51Z",
|
|
||||||
// "name":"Test",
|
|
||||||
// "orgId":"VzMuyEw_3WqiafcD",
|
|
||||||
// "userId":"VzMuyEw_3WqiafcE",
|
|
||||||
// "folderType":1
|
|
||||||
// },{
|
|
||||||
// "id":"V0Vy5Uw_3QeDAMW9",
|
|
||||||
// "created":"2016-05-25T09:39:49Z",
|
|
||||||
// "revised":"2016-05-25T09:39:49Z",
|
|
||||||
// "name":"Test Folder",
|
|
||||||
// "orgId":"VzMuyEw_3WqiafcD",
|
|
||||||
// "userId":"VzMuyEw_3WqiafcE",
|
|
||||||
// "folderType":2
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.post('/folders', function() {
|
this.post('/folders', function(db, request) {
|
||||||
|
// return {
|
||||||
|
// "id":"V0Vy5Uw_3QeDAMW9",
|
||||||
|
// "created":"2016-05-25T09:39:49Z",
|
||||||
|
// "revised":"2016-05-25T09:39:49Z",
|
||||||
|
// "name":"Test Folder",
|
||||||
|
// "orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
// "userId":"VzMuyEw_3WqiafcE",
|
||||||
|
// "folderType":2
|
||||||
|
// };
|
||||||
|
// console.log(request);
|
||||||
|
// var attrs = JSON.parse(request.requestBody).name;
|
||||||
|
// var folder = db.folders.insert(attrs);
|
||||||
|
// return folder;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.put('/folders/V0Vy5Uw_3QeDAMW9', () => {
|
||||||
return {
|
return {
|
||||||
"id":"V0Vy5Uw_3QeDAMW9",
|
"id":"V0Vy5Uw_3QeDAMW9",
|
||||||
"created":"2016-05-25T09:39:49Z",
|
"created":"2016-05-25T09:39:49Z",
|
||||||
|
@ -215,102 +187,94 @@ export default function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/users/VzMuyEw_3WqiafcE/permissions', () => {
|
this.get('/users/VzMuyEw_3WqiafcE/permissions', (db) => {
|
||||||
return [
|
return db.permissions;
|
||||||
{
|
|
||||||
"folderId":"V0Vy5Uw_3QeDAMW9",
|
|
||||||
"userId":"VzMuyEw_3WqiafcE",
|
|
||||||
"canView":true,
|
|
||||||
"canEdit":true
|
|
||||||
},{
|
|
||||||
"folderId":"VzMuyEw_3WqiafcG",
|
|
||||||
"userId":"VzMuyEw_3WqiafcE",
|
|
||||||
"canView":true,
|
|
||||||
"canEdit":true
|
|
||||||
},{
|
|
||||||
"folderId":"VzMygEw_3WrtFzto",
|
|
||||||
"userId":"VzMuyEw_3WqiafcE",
|
|
||||||
"canView":true,
|
|
||||||
"canEdit":true
|
|
||||||
},{
|
|
||||||
"folderId":"VzMygEw_3WrtFzto",
|
|
||||||
"userId":"",
|
|
||||||
"canView":true,
|
|
||||||
"canEdit":false
|
|
||||||
}
|
|
||||||
];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
this.get('/folders/VzMuyEw_3WqiafcG/permissions', (db) => {
|
||||||
return [
|
let folderId = 'VzMuyEw_3WqiafcG';
|
||||||
{
|
let permissions = db.folder_permissions
|
||||||
"folderId":"VzMuyEw_3WqiafcG",
|
console.log(permissions[0]);
|
||||||
"userId":"VzMuyEw_3WqiafcE",
|
debugger;
|
||||||
"canView":true,
|
return permissions;
|
||||||
"canEdit":true
|
// return [
|
||||||
}
|
// {
|
||||||
];
|
// "folderId":"VzMuyEw_3WqiafcG",
|
||||||
|
// "userId":"VzMuyEw_3WqiafcE",
|
||||||
|
// "canView":true,
|
||||||
|
// "canEdit":true
|
||||||
|
// }
|
||||||
|
// ];
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/folders/VzMuyEw_3WqiafcG', () => {
|
this.put('/folders/VzMuyEw_3WqiafcG/permissions', (db, request) => {
|
||||||
return {
|
let id = 'VzMuyEw_3WqiafcG';
|
||||||
"id":"VzMuyEw_3WqiafcG",
|
let roles = JSON.parse(request.requestBody).Roles;
|
||||||
"created":"2016-05-11T15:08:24Z",
|
// let permissions = db.permissions.update(id, roles[2]);
|
||||||
"revised":"2016-05-11T15:08:24Z",
|
console.log(roles);
|
||||||
"name":"Test Space",
|
debugger;
|
||||||
"orgId":"VzMuyEw_3WqiafcD",
|
return permissions;
|
||||||
"userId":"VzMuyEw_3WqiafcE",
|
|
||||||
"folderType":2
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/VzMygEw_3WrtFzto', () => {
|
this.put('/folders/:id', (db, request) => {
|
||||||
return {
|
let id = request.params.id;
|
||||||
"id": "VzMygEw_3WrtFzto",
|
let attrs = JSON.parse(request.requestBody);
|
||||||
"created": "2016-05-11T13:24:17Z",
|
let folder = db.folders.update(id, attrs);
|
||||||
"revised": "2016-05-11T13:25:51Z",
|
return folder;
|
||||||
"name": "Test",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"folderType": 1
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/V0Vy5Uw_3QeDAMW9', () => {
|
this.get('folders/:id', (db, request) => {
|
||||||
return {
|
let id = request.params.id;
|
||||||
"id":"V0Vy5Uw_3QeDAMW9",
|
return db.folders.find(id);
|
||||||
"created":"2016-05-25T09:39:49Z",
|
|
||||||
"revised":"2016-05-25T09:39:49Z",
|
|
||||||
"name":"Test Folder",
|
|
||||||
"orgId":"VzMuyEw_3WqiafcD",
|
|
||||||
"userId":"VzMuyEw_3WqiafcE",
|
|
||||||
"folderType":2
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/VzMuyEw_3WqiafcG', () => {
|
// this.get('/folders/VzMygEw_3WrtFzto', () => {
|
||||||
return {
|
// return {
|
||||||
"id": "VzMuyEw_3WqiafcG",
|
// "id": "VzMygEw_3WrtFzto",
|
||||||
"created": "2016-05-11T15:08:24Z",
|
// "created": "2016-05-11T13:24:17Z",
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
// "revised": "2016-05-11T13:25:51Z",
|
||||||
"name": "My Project",
|
// "name": "Test",
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
// "orgId": "VzMuyEw_3WqiafcD",
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
// "userId": "VzMuyEw_3WqiafcE",
|
||||||
"folderType": 2
|
// "folderType": 1
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
this.get('/folders/VzMuyEw_3WqiafcG', () => {
|
// this.get('/folders/V0Vy5Uw_3QeDAMW9', () => {
|
||||||
return {
|
// return {
|
||||||
"id": "VzMuyEw_3WqiafcG",
|
// "id":"V0Vy5Uw_3QeDAMW9",
|
||||||
"created": "2016-05-11T15:08:24Z",
|
// "created":"2016-05-25T09:39:49Z",
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
// "revised":"2016-05-25T09:39:49Z",
|
||||||
"name": "My Project",
|
// "name":"Test Folder",
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
// "orgId":"VzMuyEw_3WqiafcD",
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
// "userId":"VzMuyEw_3WqiafcE",
|
||||||
"folderType": 2
|
// "folderType":2
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
|
// this.get('/folders/VzMuyEw_3WqiafcG', () => {
|
||||||
|
// return {
|
||||||
|
// "id": "VzMuyEw_3WqiafcG",
|
||||||
|
// "created": "2016-05-11T15:08:24Z",
|
||||||
|
// "revised": "2016-05-11T15:08:24Z",
|
||||||
|
// "name": "My Project",
|
||||||
|
// "orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
// "userId": "VzMuyEw_3WqiafcE",
|
||||||
|
// "folderType": 2
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// this.get('/folders/VzMuyEw_3WqiafcG', () => {
|
||||||
|
// return {
|
||||||
|
// "id": "VzMuyEw_3WqiafcG",
|
||||||
|
// "created": "2016-05-11T15:08:24Z",
|
||||||
|
// "revised": "2016-05-11T15:08:24Z",
|
||||||
|
// "name": "My Project",
|
||||||
|
// "orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
// "userId": "VzMuyEw_3WqiafcE",
|
||||||
|
// "folderType": 2
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
|
||||||
this.get('/organizations/VzMuyEw_3WqiafcD', () => {
|
this.get('/organizations/VzMuyEw_3WqiafcD', () => {
|
||||||
return {
|
return {
|
||||||
|
@ -493,10 +457,6 @@ export default function() {
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
|
||||||
return {};
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
very helpful for debugging
|
very helpful for debugging
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue