0.6.10 • Published 6 years ago

sonet-appskit v0.6.10

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

sonet-appskit

Description

This is a set of common services and components helping to create SoNET enabled apps.

Compilation

$ npm install
$ npm run build

Installation

$ npm install sonet-appskit --save

Using the library from typescript

app.module.ts

// Import your library
import { SoNETAppsKitModule } from 'sonet-appskit';

@NgModule({
  (...)
  imports: [
    (...)
    // Specify your library as an import
    SoNETAppsKitModule
  ],
  providers: [
        SliderApiClient,
        SoNetOAuthService,
        SoNetUrlService,
        SoNetConfigService,        
        SoNetProxy,             
        (...)
    ],
    (...)
})
export class AppModule { }

Configuration

There are two different ways configuration can be provided.

1. AppsConfig Class Way

This way all configuration values are compiled into a code and they can be dynamically calculated by the code.

app.module.ts

@NgModule({
  (...)
  providers: [ 
        //register custom SoNetAppsConfig which provides the settings from the code when you need to drive them dynamically
        {
            provide: SoNetAppsConfig,
            deps: [SoNetConfigService],
            useFactory: appsConfigFactory
        },       
        (...)
    ],
    (...)
})
(...)
export function appsConfigFactory(configService: SoNetConfigService) {
    return new Config(configService);
}

apps.config.ts

@Injectable()
/**
 * Configure this SoNET Apps Kit here.
 */
export class Config extends SoNetAppsConfig {
    /** Base url of installed SoNET engine against which you are issuing API calls. There are many SoNET engines already deployed throughout the world. An example would be: https://www.lpk7.com. You can always quickly install your own either on premise or in the cloud. Please refer to this link: http://www.iradek.com/Products/ */
    api_baseUrl = "";
    /** Your Client ID obtained by registering via http://store.iradek.com/Client/Register */
    oauth_client_id =  "";
    /** Your Client Secret obtained by registering via http://store.iradek.com/Client/Register */
    oauth_client_secret = "";
    /** Name of the Site when Site-level access is being requested. */
    siteName = "";
    /** Name of the user when ResourceOwner grant is used. */
    userName = "";
    /** User password when ResourceOwner grant is used. */
    userPassword = "";
    /** Whether the user password is already encrypted (ResourceOwner grant). */
    passwordAlreadyEncrypted = false;
    /** Supported OAuth grant type. Change it before API call to adjust oauth grant. With ClientCredentials grant you can call APIs that do not require Site user. With ResourceGrant credentials you call APIs that act on behalf of Site user. See http://[base url of SoNET]/api/help for more details.  */
    oAuthGrant = OAuthGrant.ClientCredentials;
    /** Whether to enable extra logging to a console that might help diagnose api calls made by this library */
    logging = false;
}

2. External JSON File Way

This way all configuration values compiled into a code as in a previous example can be overriden by a static, external json file. This can be advantageous when file needs to 'survive' software updates.

app.module.ts

@NgModule({
  (...)
  providers: [ 
        //register configLoader to load the settings from a file; those override code-based SoNetAppsConfig settings when needed
        {
            provide: APP_INITIALIZER,
            useFactory: configLoader,
            deps: [SoNetConfigService],
            multi: true
        },
        (...)
    ],
    (...)
})
(...)
//point the loader to a file with configuration settings
const configFilePath = 'assets/apps.config.json';
export function configLoader(configService: SoNetConfigService) {
    //Note: this factory needs to return a function that returns a promise
    return () => configService.loadAsync(configFilePath);
}

apps.config.ts

{
    "api_baseUrl": "",
    "oauth_client_id": "",
    "oauth_client_secret": "",
    "siteName" : "",
    "userName" : "",
    "userPassword" : "",
    "passwordAlreadyEncrypted" : false,
    "oAuthGrant" : "ClientCredentials",                
    "logging": false
}

SoNET Engine

For more information about SoNET engine please visit: http://www.iradek.com

License

MIT © i-Radek Software

0.6.10

6 years ago

0.6.9

6 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.14

7 years ago

0.4.13

7 years ago

0.4.12

7 years ago

0.4.11

7 years ago

0.4.10

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.27

7 years ago

0.3.26

7 years ago

0.3.25

7 years ago

0.3.24

7 years ago

0.3.23

7 years ago

0.3.22

7 years ago

0.3.21

7 years ago

0.3.20

7 years ago

0.3.19

7 years ago

0.3.18

7 years ago

0.3.17

7 years ago

0.3.16

7 years ago

0.3.15

7 years ago

0.3.14

7 years ago

0.3.13

7 years ago

0.3.12

7 years ago

0.3.11

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago