I am Developing a E-Commerce Web Application as a part of my learning using Spring Hibernate and AngularJs.
I have written some Rest API's Controllers in Spring and then from the Web Component i am invoking the same using Angular Js like the below :-
storezillaadminapp.service('CategoryService',function($http){
var listCategories = [];
this.getAllCategories = function() {
return $http.get(_contextPath+'/categories');
};
this.addCategory = function(category) {
return $http.post(_contextPath+'/categories/add',category);
};
this.updateCategory = function(category) {
return $http.put(_contextPath+'/categories/edit',category);
};
this.removeCategory = function(id) {
return $http.delete(_contextPath+'/categories/remove/'+id);
};
});
The concern here is, It is a Good idea to expose the rest api's from javascript code like the above ? The reason for asking this is that, at the end of the day, all the js files get downloaded onto the clients machines making your API more vulnerable. What would be the ways to hide this even if the approach is used.
I have seen lots of applications which write some Server side Ajax Code to handle Ajax Requests.
Thanks !
storezillaadminapp
to something more readable if possible. camelCase (i.e.storeZillaAdminApp
, maybe something shorter), would work wonders.