|
1 | 1 | /** |
2 | | -* @module SDK Index |
| 2 | +* @module SDKModule |
3 | 3 | * @author Jonathan Casarrubias <t:@johncasarrubias> <gh:jonathan-casarrubias> |
4 | 4 | * @license MTI 2016 Jonathan Casarrubias |
5 | 5 | * @description |
6 | | -* The SDK Index is automatically built by the LoopBack SDK Builder. |
| 6 | +* The SDKModule is a generated Software Development Kit automatically built by |
| 7 | +* the LoopBack SDK Builder open source module. |
7 | 8 | * |
8 | | -* The SDK Index will temporally keep providing access to everything in the SDK |
9 | | -* including services. This is because will maintain backwards compatibility for those |
10 | | -* Applications below Angular 2 RC 5 version that does not support NgModule just yet. |
| 9 | +* The SDKModule provides Angular 2 >= RC.5 support, which means that NgModules |
| 10 | +* can import this Software Development Kit as follows: |
11 | 11 | * |
12 | | -* IMPORTANT NOTE: |
13 | 12 | * |
14 | | -* If your application is equal or above RC 5 It is recommended to import the SDK |
15 | | -* Module located in ./sdk.module.ts and follow the instructions. |
| 13 | +* APP Route Module Context |
| 14 | +* ============================================================================ |
| 15 | +* import { NgModule } from '@angular/core'; |
| 16 | +* import { BrowserModule } from '@angular/platform-browser'; |
| 17 | +* // App Root |
| 18 | +* import { AppComponent } from './app.component'; |
| 19 | +* // Feature Modules |
| 20 | +* import { SDKModule } from './shared/sdk/sdk.module'; |
| 21 | +* // Import Routing |
| 22 | +* import { routing } from './app.routing'; |
| 23 | +* @NgModule({ |
| 24 | +* imports: [ |
| 25 | +* BrowserModule, |
| 26 | +* routing, |
| 27 | +* SDKModule.forRoot() |
| 28 | +* ], |
| 29 | +* declarations: [ AppComponent ], |
| 30 | +* bootstrap: [ AppComponent ] |
| 31 | +* }) |
| 32 | +* export class AppModule { } |
16 | 33 | * |
17 | | -* Also, It is recommended for you to start upgrading your application in order to |
18 | | -* support NgModules before backwards support is also dropped by Angular. |
19 | | -* |
20 | | -* READ: https://angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html#!#5-cleanup |
21 | | -**/ |
22 | | -<%- buildModuleImports(models, true) %> |
23 | | -/** |
24 | | -* IMPORTANT: API_PROVIDERS WILL BE DEPRECATED WHEN ANGULAR 2 IS STABLE |
25 | | -* PLEASE MIGRATE YOUR PROJECT AS SOON AS POSSIBLE. |
26 | | -* ONCE ANGULAR 2 IS STABLE I WON'T KEEP SUPPORTING API PROVIDERS. |
27 | | -* USER NGMODULE INSTEAD LOCATED IN ./sdk.module.ts |
28 | 34 | **/ |
29 | | -export const API_PROVIDERS: any[] = [ |
30 | | - LoopBackAuth, |
31 | | - ErrorHandler, |
32 | | - LoggerService, |
33 | | - JSONSearchParams,<% |
34 | | -Object.keys(models).forEach(function(modelName, i, arr) { |
35 | | - modelName = modelName[0].toUpperCase() + modelName.slice(1); |
36 | | -%> |
37 | | - <%- modelName %>Api<%= i < arr.length -1 ? ',' : '' %><% |
38 | | -});%> |
39 | | -]; |
| 35 | +<%- buildModuleImports(models, false) %> |
| 36 | + |
| 37 | +@NgModule({ |
| 38 | + imports: [ CommonModule, HttpModule ], |
| 39 | + declarations: [ ], |
| 40 | + exports: [ ], |
| 41 | + providers: [ ] |
| 42 | +}) |
| 43 | + |
| 44 | +export class SDKModule { |
| 45 | + static forRoot(): ModuleWithProviders { |
| 46 | + return { |
| 47 | + ngModule: SDKModule, |
| 48 | + providers: [ |
| 49 | + RealTime, |
| 50 | + LoopBackAuth, |
| 51 | + ErrorHandler, |
| 52 | + LoggerService, |
| 53 | + JSONSearchParams,<% |
| 54 | + Object.keys(models).forEach(function(modelName, i, arr) { |
| 55 | + modelName = modelName[0].toUpperCase() + modelName.slice(1); |
| 56 | + %> |
| 57 | + <%- modelName %>Api<%= i < arr.length -1 ? ',' : '' %><% |
| 58 | + });%> |
| 59 | + ] |
| 60 | + }; |
| 61 | + } |
| 62 | +} |
| 63 | + |
40 | 64 | export * from './models/index'; |
41 | 65 | export * from './services/index'; |
42 | 66 | export * from './lb.config'; |
43 | | -export * from './sdk.module'; |
44 | 67 | <% if ( isIo === 'enabled' ){ -%>export * from './sockets/index'; |
45 | 68 | <% } |
46 | 69 | -%> |
47 | | - |
|
0 commit comments