Giter Club home page Giter Club logo

ngx-envconfig's People

Contributors

kmanaseryan avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

danko-d

ngx-envconfig's Issues

Error in production mode

Hello,

while using the ngx-envconfig library, i can't use the production mode due to an error during application startup:

production main.91723b488af13390246c.js:1 TypeError: Cannot read property 'HOST_API' of undefined at t.getApi (main.91723b488af13390246c.js:1) at t.intercept (main.91723b488af13390246c.js:1) at t.handle (main.91723b488af13390246c.js:1) at t.intercept (main.91723b488af13390246c.js:1) at t.handle (main.91723b488af13390246c.js:1) at t.handle (main.91723b488af13390246c.js:1) at e.project (main.91723b488af13390246c.js:1) at e._tryNext (main.91723b488af13390246c.js:1) at e._next (main.91723b488af13390246c.js:1) at e.next (main.91723b488af13390246c.js:1)

do you have an idea how i can fix this error?

thanks in advance,

ModuleWithProviders lacks generic type argument.

Describe the bug
When running in Angular 9.1.0, I get the following output:

    ERROR in node_modules/ngx-envconfig/src/config.module.d.ts:7:37 - error NG6005: ConfigModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
    
    7     static forRoot(env: EnvConfig): ModuleWithProviders;

I would fix this, but I have no idea what type argument it's expecting (I'm new to Angular).

To Reproduce
Steps to reproduce the behavior:

  1. Install Angular 9.1.0 and create a new empty project
  2. Install ngx-envconfig
  3. Configure per the ngx-envconfig readme
  4. ng serve and observe the error

Expected behavior
The module to load and ngx-envconfig to be available in my Angular components.

Environment (please complete the following information):

  • Angular Version: 9.1.0
  • ngx-envconfig Version: 7.0.1
  • TypeScript version: 3.8.3

Suggestion: Remove getApi from ConfigService

The process of building an API url is probably outside the scope of this library due to a wide variety of application specific conventions for APIs. For instance, the getApi implementation is useless if you have an API with multiple hosts.

In the interest of keeping this library focused on "environment configuration," I would propose you remove the getApi method from ConfigService.

Can't build production environment

While running the command ng build --configuration=production

I am getting the following error:

ERROR in Error during template compile of 'AppModule'
Function calls are not supported in decorators but 'ConfigModule' was called.

Here is the code that I am using the app.module file

`import { ConfigModule, ConfigService } from 'ngx-envconfig';

import { environment } from '../environments/environment'; // <-- add this line

const appRoutes: Routes = [
{ path: 'charts/:id', component: PiechartComponent }
];

@NgModule({
declarations: [
AppComponent,
BarchartComponent,
LinechartComponent,
PiechartComponent
],
imports: [
BrowserModule,
HttpModule,
HttpClientModule,
AmChartsModule,
RouterModule.forRoot(appRoutes),
ConfigModule.forRoot(environment) // <-- pass environment variable
],
providers: [ServerService],
bootstrap: [AppComponent]
})
export class AppModule { }`

Update README

In getting started code snippets, ConfigService and ConfigeModule are being used from local module folder instead of installed ones.

Error when running jest test on the component spec file using

Describe the bug
After using this package my component tests started failing with the following error

To Reproduce
Steps to reproduce the behavior:

  1. jest test

FAIL apps/my-app/src/app/auth/login/login.component.spec.ts ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Here's what you can do: • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in your config. • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option. You'll find more details and examples of these config options in the docs: https://jestjs.io/docs/en/configuration.html Details: D:\MYapp\mayapp-rocket-shorts-ng7\node_modules\ngx-envconfig\index.js:1 ({"Object.":function(module,exports,require,__dirname,__filename,global,jest){export { ConfigModule } from './src/config.module'; ^^^^^^ SyntaxError: Unexpected token export at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17) at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25) at Object. (apps/my-app/src/app/auth/login/login.component.ts:1162:25)`

I have been trying to fix this from hrs. But not able to.
I am on angular v7.
I tried upgrading from jest 23.6.0 to 24.7.1
tried upgrading from jest-preset-angular 6.0.2 to 7.1.0
upgrading angular-builders/jest from 7.2.1 to 7.4.2
But this error still persists on both the earlier and the later vesions stated above.

Can you give me an example of how we can use this package and still write a working jest test.

ngx-envconfig _config is undefined

Describe the bug
TypeError: Cannot read property 'HOST_API' of undefined

To Reproduce
Steps to reproduce the behavior:

  1. install ngx-envconfig with npm
  2. add all config files and imports in modules
  3. ng serve your app
  4. See error 1: "config.service.js:42 TypeError: Cannot read property 'HOST_API' of undefined
    at ConfigService.push../node_modules/ngx-envconfig/src/config.service.js.ConfigService.get (config.service.js:64)
    at new ApiAccessService (api-access.service.ts:10)
    at _createClass (core.js:26473)
    at _createProviderInstance (core.js:26436)
    at resolveNgModuleDep (core.js:26383)
    at _createClass (core.js:26473)
    at _createProviderInstance (core.js:26436)
    at resolveNgModuleDep (core.js:26383)
    at _createClass (core.js:26471)
    at _createProviderInstance (core.js:26436)"
    Error 2 "core.js:9110 ERROR TypeError: error.json is not a function
    at SafeSubscriber._error (config.service.js:43)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:185)
    at SafeSubscriber.error (Subscriber.js:137)
    at Subscriber._error (Subscriber.js:75)
    at Subscriber.error (Subscriber.js:55)
    at MapSubscriber._error (Subscriber.js:75)
    at MapSubscriber.error (Subscriber.js:55)
    at FilterSubscriber._error (Subscriber.js:75)
    at FilterSubscriber.error (Subscriber.js:55)
    at MergeMapSubscriber._tryNext (mergeMap.js:49)"

Expected behavior
No errors

Environment (please complete the following information):

  • Angular version v8.1
  • ngx-envconfig v7.0.1
  • TypeScript version v3.4.3

Additional context
From what I've see, the _config variable (in config.service.js) is never initialized in time
Is there a way to ensure the _config is fully loaded?
Thank you!

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.