In order to streamline my approach, I utilize a custom Angular service where all endpoint information is stored alongside other application-specific settings:
angular.module("appModule").value("appSettings", {
title: "My application",
version: "0.0.0.1",
webApiHost: "http://localhost:33000/",
customersEndpoint: "api/customers",
});
This setup allows for easy identification of references by searching for the appSettings.customersEndpoint
string within the codebase. Here's an example from the client side:
(function (angular) {
var customersFactory = function ($http, appSettings) {
var factory = {};
factory.getAll = function () {
return $http.get(appSettings.webApiHost + appSettings.customersEndpoint);
}
return factory;
};
customersFactory.$inject = ["$http", "appSettings"];
angular.module("appModule").factory("customersFactory", customersFactory);
}(angular));
It’s worth noting that while this method can be effective, individuals may still opt to obfuscate endpoints using techniques like string concatenation. Ultimately, there isn't a foolproof solution — just exercise caution!