Files
meanTorrent/modules/requests/client/services/requests-comments.client.service.js

52 lines
1.3 KiB
JavaScript

(function () {
'use strict';
// Users service used for communicating with the users REST endpoint
angular
.module('requests.services')
.factory('RequestsCommentsService', RequestsCommentsService);
RequestsCommentsService.$inject = ['$resource', 'CacheFactory', 'RequestsService'];
function RequestsCommentsService($resource, CacheFactory, RequestsService) {
var requestsCache = CacheFactory.get('requestsCache') || CacheFactory.createCache('requestsCache');
var removeCache = function (res) {
requestsCache.removeAll();
return new RequestsService(res.resource);
};
var Comments = $resource('/api/reqComments/:requestId/:commentId/:subCommentId', {
requestId: '@_requestId',
commentId: '@_commentId',
subCommentId: '@_subCommentId'
}, {
get: {
method: 'GET',
cache: requestsCache
},
query: {
method: 'GET',
cache: requestsCache
},
update: {
method: 'PUT',
interceptor: {response: removeCache}
},
save: {
method: 'POST',
interceptor: {response: removeCache}
},
remove: {
method: 'DELETE',
interceptor: {response: removeCache}
},
delete: {
method: 'DELETE',
interceptor: {response: removeCache}
}
});
return Comments;
}
}());