Giter Site home page Giter Site logo

angular-environment's People

Contributors

brendanoffer avatar jonshaffer avatar juanpablob avatar pawelgorka avatar quest avatar rars avatar sirwesley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

angular-environment's Issues

How to use it with routes?

Hi,

Thanks for such a great plug-in. I want to use the 'envService' in routes like below:

Any suggestion on how to use this?

var routeDetails = function ($routeProvider,$locationProvider,envService){
var SERVER_ENDPOINT = envService.read('staticUrl');

$routeProvider.
when('/', {
    templateUrl: SERVER_ENDPOINT + '/partials/home.html',
    controller: 'Controller',
}). when('/guides', {
    templateUrl: SERVER_ENDPOINT + '/partials/guides.html',
    controller: 'GuidesController',
}

}

Thanks,
Shailendra

Unit tests

It'd be great to see some unit tests, other than that thanks for making this!

Defaults block is not actually the default

According to the documentation, the 'defaults' block is supposed to be the catch-all area, however in testing it appears that 'development' is actually the catch-all section. Recommend fixing the code to make the 'defaults' block the catch-all area if there are no matches, or update the documentation to note that 'development' is the catch-all area if there are no matches.

Domains and Subdomains

Hi @juanpablob ,

I'm playing with the following config:

          domains: {
              local: 'localhost',
              dev: ['dev.mydomain.com'],
              qa: ['qa.mydomain.com'],
              production: ['mydomain.com']
          },
          vars: {
              local: {
                  api_url: 'http://127.0.0.1:8000/',
              },
              dev: {
                  api_url: 'http://dev.mydomain.com:8001/',
              },
              qa:{
                  api_url: 'http://qa.mydomain.com:8001/'
              },
              production: {
                  api_url: 'http://mydomain.com:8001/',
              }
          }
      });
     envServiceProvider.check();

When visiting qa.mydomain.com, it still queries the url for my production env, and the same for dev.

`Error: No pending request to flush !` with $http

Hi,

First of all, this is a nifty little module.

The moment when I added this module it started to break my unit test. Basically any place where I use an environmental variable in an $http call path, it breaks with the following error:
Error: No pending request to flush !

Request: Support a 'defaults' set in config vars

Hi there,

Thank you for the great plugin. One useful feature i'd like to see is the ability to set defaults in the vars object, that get used if not defined in a specific environment - something like this:

# coffeescript

envServiceProvider.config
    domains:
      development: [
        'localhost'
      ]
      staging: [
        'staging.acme.com'
      ]
      production: [
        'acme.com'
      ]
    vars:
      defaults:
        s3Bucket: 'abcdefg123456789'
      development:
        apiUrl: 'https://localhost/api/url'
      staging:
        apiUrl: 'https://staging.acme.com/api/url'
      production:
        apiUrl: 'https://www.acme.com/api/url'
        s3Bucket: 'hijklmn987654321'

envServiceProvider.check()

With the above config, I would expect envService.read('s3Bucket') to return hijklmn987654321 for production, and abcdefg123456789 for development and staging.

This would be a small but useful addition when dealing with large sets of environments/variables.

Thanks again!

console.log(v.domain);

Having this spam between each of my unit tests is incredibly annoying. Is there any way for me to stop it from happening?

`npm install` does not pull down index.js

I think that after merging in PR #4 an NPM publish is required.

Currently when I install it is downloaded without.

foo$ npm install angular-environment
[email protected] node_modules\angular-environment
foo$ ls node_modules/angular-environment/
bower.json  bower_components/  demo/  dist/  gulpfile.js  LICENSE  package.json  README.md  src/

check() not matching correctly

Hi.. @juanpablob I think we are currently having this issue on the latest 1.0.7 version.
This is related with #22 #23 #19 I think so.
It's not matching correctly when using subdomains like:

dev: 'dapp.test.com',
test: 'tapp.test.com',
production: 'app.test.com'.
It's always setting as the production to be the environment, incorrectly.

I think the issue is on the check() method and this commit:
3cd588e

Could you please take a look?

Use envService in config section

Thanks Juan you write a very useful module and I looking forward to use this on my next angular project.

But I'd like to use the envService in the Angular config section like so:

angular.module('myModule', []).config(function(envService) { 
    console.log(envService.get());
}).

I don't think that is possible because envService is after the config phase available. Do you have a tipp to solve this issue?

How to use this plugin when my angular app is running on node

First of all please excuse me as this is not a bug, rather than I need some information/ help regarding this plugin.
This plugin looks promising to me, and I believe there must be a way to add this in my project.

My app is running on node environment, where I run it using:

npm run start:development

In such case, how can I set the environment to use "development".

Any help or pointers are highly appreciated.

Thanks.

Syntax error in "full example"

Upon copying and pasting the example into my app, I got an angularJS error: "Failed to instantiate module ..."_

I spotted a syntax error where the closing brace for the "test" element did not have an ending comma after the closing brace. Please update the documentation with working syntax.

Thanks for contributing this library!

Configuring protocols...

It would be nice if you're running different environments using different protocols (http vs https) for url/uri "things" to automatically get the current protocol attached when read. For example:

Anything of the form: '//...' would get the window.location.protocol attached

or

Anything named: ...Url or ... Uri would get same thing.

of the two, I prefer the first since naming habits are more or less the property of an individual but the form of a uri/url is defined externally.

Causing errors in Jasmine test

Hi,

I have started using your library and it works perfectly in the application, however it causes the error:

undefined is not an object (evaluating 'this.data.vars[this.get()]') in .../bower_components/angular-environment/src/angular-environment.js (line 59)

when called in a unit test.

Thanks

domain issue, www and without

I have the following config:

domains: {
              dev: 'localhost',
              staging: ['staging.mydomain.com'],
              production: ['mydomain.com']
          },
          vars: {
              dev: {
                  api_url: 'http://localhost:8000/',
              },
              staging: {
                  api_url: 'http://staging.mydomain.com:8001/',
              },
              production: {
                  api_url: 'http://mydomain.com:8001/',
              }
          }
      });
     envServiceProvider.check();

When I go to mydomain.com, everything works fine, it's using the production environment but when I go to www.mydomain.com, it's recognizing it as the dev environment. I tried adding www.mydomain.com to the list of domain names but it didn't fix it at all.

Am I doing something wrong? Thanks!

Use envService in factory section

Hi and first of all, thanks for this useful module.

I would like to use environment variables in a factory section since I need these values to instantiate another module: https://github.com/btford/angular-socket-io

My code look like this and I have to comment/uncomment some lines when I migrate from one env to anoher...

myApp.factory('mySocket', function (socketFactory) {
    // TODO: choose proper URL : need access to 'envService' here...
    //var myIoSocket = io.connect('http://127.0.0.1:12345'); // local
    var myIoSocket = io.connect('http://XXX.XXX.XXX.XXX:9000'); // production
    return socketFactory({
        ioSocket: myIoSocket
    });
});

Any suggestion on the proper way to do that?

I think that's not a very different question than this one: #10

Thanks in advance

Subdomains

Hi

Looking at the source code, I think that your check() may not work for subdomains as you intend:

If

var domain = "example.com"
var location = "https://subdomain.example.com";
var result = location.match(new RegExp("^http(s)?:\/\/" + domain);  // null = no match

May I suggest something along the lines of:

var regex = new RegExp(domain + '$');  // $ tests for 'domain' at the end of the string
var result = regex.test(window.location.hostname);

I could submit a Pull Request - but I'm new to this stuff - it would be my first PR!
:-)

Version 1.0.3 heroku & subdomains issue

I have been using the version 1.0.2 like this:

  domains: {
    development: ['localhost'],
    staging: ['herokuapp.com'],
    production: ['domain.com']
  }

And it worked.

Then when I upgraded to the version 1.0.3 and the staging domain was not recognised because it was returning the vars from development domain.

What I did to make did to make it work again was:

 domains: {
    development: ['localhost'],
    staging: ['staging-frontend-domain.herokuapp.com'],
    production: ['www.domain.com']
  }

The only difference is that now staging and production have the subdomain specified.

It will be a good idea to write some tests before releasing a new version... just saying...

Angular environment returning development

So we have a very strange problem. We use this package on almost every angular app we have, and it's been flawless, except for on our most recent project. I have checked the code 1000 times and it's literally copied and pasted from the other projects so I'm 99% sure it works, but no matter what we do Angular Environment always returned development.

I'm not sure how this can be because we have 10 or more implementations that worked without issue, but it seems to be the case.

Anything I can try to attempt to get it to work?

Edit: also should note I've tried manually calling set('staging') and even that doesn't work. Every time it goes to actually read the environment and the variables, it grabs the development ones.

domain name

Hi,
This is not an issue, just a question.
How does envService determine the domain name? By URL or HostName?

Thanks,
sadfeen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.