cobuild-angular-stack
Version:
Base stack angular sass jade gulp
46 lines (32 loc) • 1.05 kB
JavaScript
/**
* Created by garusis on 8/06/16.
*/
(function (module) {
'use strict';
UnikoServiceProvider.$inject = [];
function UnikoServiceProvider() {
var $provider = this;
var urlBase = "http://uniko.co:3000/api/v2";
var authHeader = 'authorization';
function getHost(url) {
var m = url.match(/^(?:https?:)?\/\/([^\/]+)/);
return m ? m[1] : null;
}
var urlBaseHost = getHost(urlBase) || location.host;
var configs = {
baseUrl: urlBase
};
this.config = function (nConfigs) {
configs = angular.extend({}, configs, nConfigs);
return configs;
};
function UnikoService(resource) {
this.resourceUrl = resource ? configs.baseUrl + '/' + resource : configs.baseUrl;
}
this.$get = function () {
return UnikoService;
};
this.$get.$inject = [];
}
module.provider('UnikoService', UnikoServiceProvider)
})(angular.module('uniko'));