mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Added tests and support for angular-environment
This commit is contained in:
parent
e69fe60f2d
commit
f57a6d7b02
30
angular-environment/angular-environment-tests.ts
Normal file
30
angular-environment/angular-environment-tests.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/// <reference path="angular-environment.d.ts" />
|
||||
var envServiceProvider: ng.environment.ServiceProvider;
|
||||
var envService: ng.environment.Service;
|
||||
|
||||
envServiceProvider.config({
|
||||
domains: {
|
||||
development: ['localhost', 'dev.local'],
|
||||
production: ['acme.com', 'acme.net', 'acme.org']
|
||||
},
|
||||
vars: {
|
||||
development: {
|
||||
apiUrl: '//localhost/api',
|
||||
staticUrl: '//localhost/static'
|
||||
},
|
||||
production: {
|
||||
apiUrl: '//api.acme.com/v2',
|
||||
staticUrl: '//static.acme.com'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
envServiceProvider.check();
|
||||
|
||||
envService.get();
|
||||
|
||||
envService.set('production');
|
||||
|
||||
var isProd: boolean = envService.is('production');
|
||||
|
||||
var val: any = envService.read('apiUrl');
|
||||
52
angular-environment/angular-environment.d.ts
vendored
Normal file
52
angular-environment/angular-environment.d.ts
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
// Type definitions for angular-environment v1.0.4
|
||||
// Project: https://github.com/juanpablob/angular-environment
|
||||
// Definitions by: Matt Wheatley <https://github.com/terrawheat>
|
||||
// Definitions: https://github.com/LiberisLabs
|
||||
|
||||
declare module ng.environment {
|
||||
interface ServiceProvider {
|
||||
/**
|
||||
* Sets the configuration object
|
||||
*/
|
||||
config: (config: ng.environment.Config) => void;
|
||||
/**
|
||||
* Evaluates the current domain and
|
||||
* loads the correct environment variables.
|
||||
*/
|
||||
check: () => void;
|
||||
}
|
||||
interface Service {
|
||||
/**
|
||||
* Retrieve the current environment
|
||||
*/
|
||||
get: () => string,
|
||||
|
||||
/**
|
||||
* Force sets the current environment
|
||||
*/
|
||||
set: (environment: string) => void,
|
||||
|
||||
/**
|
||||
* Evaluates current environment against
|
||||
* environment parameter.
|
||||
*/
|
||||
is: (environment: string) => boolean,
|
||||
|
||||
/**
|
||||
* Retrieves the correct version of a
|
||||
* variable for the current environment.
|
||||
*/
|
||||
read: (key: string) => any;
|
||||
}
|
||||
|
||||
interface Config {
|
||||
/**
|
||||
* Map of domains to their environments
|
||||
*/
|
||||
domains: { [environment: string]: Array<string> },
|
||||
/**
|
||||
* List of variables split by environment
|
||||
*/
|
||||
vars: { [environment: string]: { [variable: string]: any }},
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user