6.20.2258 • Published 3 months ago

@veeroute/lss-routing-angular v6.20.2258

Weekly downloads
1
License
Veeroute
Repository
-
Last release
3 months ago

@veeroute/lss-routing-angular@6.20.2258

General usage

In your Angular project:

// without configuring providers
import { LssRoutingApiModule } from '@veeroute/lss-routing-angular';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
    imports: [
        LssRoutingApiModule,
        // make sure to import the HttpClientModule in the AppModule only,
        // see https://github.com/angular/angular/issues/20575
        HttpClientModule
    ],
    declarations: [ AppComponent ],
    providers: [],
    bootstrap: [ AppComponent ]
})
export class AppModule {}
// configuring providers
import { LssRoutingApiModule, Configuration, ConfigurationParameters } from '@veeroute/lss-routing-angular';

export function apiConfigFactory (): Configuration {
  const params: ConfigurationParameters = {
    // set configuration parameters here.
  }
  return new Configuration(params);
}

@NgModule({
    imports: [ LssRoutingApiModule.forRoot(apiConfigFactory) ],
    declarations: [ AppComponent ],
    providers: [],
    bootstrap: [ AppComponent ]
})
export class AppModule {}
// configuring providers with an authentication service that manages your access tokens
import { LssRoutingApiModule, Configuration } from '@veeroute/lss-routing-angular';

@NgModule({
    imports: [ LssRoutingApiModule ],
    declarations: [ AppComponent ],
    providers: [
      {
        provide: Configuration,
        useFactory: (authService: AuthService) => new Configuration(
          {
            basePath: environment.apiUrl,
            accessToken: authService.getAccessToken.bind(authService)
          }
        ),
        deps: [AuthService],
        multi: false
      }
    ],
    bootstrap: [ AppComponent ]
})
export class AppModule {}
import { DefaultApi } from '@veeroute/lss-routing-angular';

export class AppComponent {
    constructor(private apiGateway: DefaultApi) { }
}

Note: The LssRoutingApiModule is restricted to being instantiated once app wide. This is to ensure that all services are treated as singletons.

Using multiple OpenAPI files / APIs / LssRoutingApiModules

In order to use multiple LssRoutingApiModules generated from different OpenAPI files, you can create an alias name when importing the modules in order to avoid naming conflicts:

import { LssRoutingApiModule } from 'my-api-path';
import { LssRoutingApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  imports: [
    LssRoutingApiModule,
    OtherApiModule,
    // make sure to import the HttpClientModule in the AppModule only,
    // see https://github.com/angular/angular/issues/20575
    HttpClientModule
  ]
})
export class AppModule {

}

Set service base path

If different than the generated base path, during app bootstrap, you can provide the base path to your service.

import { BASE_PATH } from '@veeroute/lss-routing-angular';

bootstrap(AppComponent, [
    { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);

or

import { BASE_PATH } from '@veeroute/lss-routing-angular';

@NgModule({
    imports: [],
    declarations: [ AppComponent ],
    providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
    bootstrap: [ AppComponent ]
})
export class AppModule {}

Using @angular/cli

First extend your src/environments/*.ts files by adding the corresponding base path:

export const environment = {
  production: false,
  API_BASE_PATH: 'http://127.0.0.1:8080'
};

In the src/app/app.module.ts:

import { BASE_PATH } from '@veeroute/lss-routing-angular';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [ ],
  providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
  bootstrap: [ AppComponent ]
})
export class AppModule { }
6.20.2258

3 months ago

6.20.2252

3 months ago

6.19.2236

4 months ago

6.18.2232

4 months ago

6.17.2224

4 months ago

6.16.2174

6 months ago

6.16.2177

6 months ago

6.15.2142

7 months ago

6.14.2133

8 months ago

6.10.2076

10 months ago

6.13.2112

9 months ago

6.9.2071

10 months ago

6.12.2101

9 months ago

6.11.2097

9 months ago

6.8.2055

10 months ago

6.7.2022

12 months ago

6.6.2006

12 months ago

6.5.1990

1 year ago

6.3.1926

1 year ago

6.2.1912

1 year ago

6.4.1962

1 year ago

6.1.1902

1 year ago

5.12.1836

1 year ago

5.11.1826

1 year ago

5.8.1766

2 years ago

5.6.1748

2 years ago

5.4.1715

2 years ago

5.3.1702

2 years ago

5.1.1673

2 years ago

4.9.1651

2 years ago

4.7.1605

2 years ago

4.9.1653

2 years ago

4.7.1607

2 years ago

4.7.1601

2 years ago

4.7.1599

2 years ago

3.15.183137

2 years ago

3.12.180165

2 years ago

3.10.176314

3 years ago

3.10.176203

3 years ago

3.10.176173

3 years ago

3.9.175411

3 years ago

4.0.173861-RC

3 years ago

3.9.172873

3 years ago

3.8.171175

3 years ago

3.8.168904

3 years ago

3.8.168680

3 years ago

3.8.168672

3 years ago

3.8.168700

3 years ago

3.7.167066

3 years ago

3.7.166798

3 years ago

3.7.166794

3 years ago

3.6.163909

3 years ago

3.6.163884

3 years ago

3.6.163569

4 years ago

3.6.163551

4 years ago

3.6.163543

4 years ago

3.6.163430

4 years ago

3.6.163438

4 years ago

3.6.163373

4 years ago

3.6.163087

4 years ago

3.6.163082

4 years ago

3.6.163079

4 years ago