Skip to content

Commit

Permalink
fix: fixed aot error with forRoot method
Browse files Browse the repository at this point in the history
  • Loading branch information
Supamiu committed Sep 25, 2018
1 parent e5ca0f1 commit f251299
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 47 deletions.
2 changes: 0 additions & 2 deletions index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"docs:generate": "npm run docs:clean && typedoc --out docs --excludePrivate --mode file --exclude \"**/*+(index|spec|entry).ts\" ./src",
"docs:clean": "del-cli docs/"
},
"typings": "./angular-client.d.ts",
"typings": "./xivapi-client.d.ts",
"author": "Supamiu",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion public_api.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './index';
// Public classes.
export * from './src/xivapi-client';
17 changes: 8 additions & 9 deletions src/xivapi-client.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { XivapiService } from './xivapi.service';
import { HttpClientModule } from '@angular/common/http';

/**
* @hidden
*/
export const XIVAPI_KEY: InjectionToken<string> = new InjectionToken('XIVAPI_KEY');
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { XivapiServiceFactory } from './xivapi-service-factory';

@NgModule({
imports: [
Expand All @@ -21,8 +17,11 @@ export class XivapiClientModule {
return {
ngModule: XivapiClientModule,
providers: [
XivapiService,
{provide: XIVAPI_KEY, useValue: key}
{
provide: XivapiService,
useFactory: XivapiServiceFactory,
deps: [key, HttpClient]
}
]
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts → src/xivapi-client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { XivapiClientModule, XIVAPI_KEY } from './xivapi-client.module';
export { XivapiClientModule } from './xivapi-client.module';
export { XivapiService } from './xivapi.service';
export * from './model/index';
6 changes: 6 additions & 0 deletions src/xivapi-service-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { XivapiService } from './xivapi.service';
import { HttpClient } from '@angular/common/http';

export function XivapiServiceFactory(key: string, http: HttpClient): XivapiService {
return new XivapiService(key, http);
}
5 changes: 2 additions & 3 deletions src/xivapi.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Inject, Injectable } from '@angular/core';
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import {
Expand All @@ -11,7 +11,6 @@ import {
XivapiRequestOptions,
XivapiSearchOptions
} from './model';
import { XIVAPI_KEY } from './xivapi-client.module';
import { CharacterResponse, CharacterVerification } from './model/schema/character';

@Injectable()
Expand All @@ -22,7 +21,7 @@ export class XivapiService {
*/
public static readonly API_BASE_URL: string = 'https://xivapi.com';

constructor(@Inject(XIVAPI_KEY) protected readonly apiKey: string, private http: HttpClient) {
constructor(@Inject('XIVAPI_KEY') protected readonly apiKey: string, private http: HttpClient) {
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/xivapi.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestBed } from '@angular/core/testing';
import { SearchIndex, XivapiService } from '../src';
import { SearchIndex, XivapiService } from '../src/xivapi-client';
import { HttpClientTestingModule, HttpTestingController, TestRequest } from '@angular/common/http/testing';
import { HttpClient } from '@angular/common/http';

Expand Down
58 changes: 29 additions & 29 deletions tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"strict": true,
"module": "es2015",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"target": "es2015",
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
]
},
"files": [
"public_api.ts",
"node_modules/zone.js/dist/zone.js.d.ts"
],
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "xivapi-client.js",
"flatModuleId": "@xivapi/angular-client"
}
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"strict": true,
"module": "es2015",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"target": "es2015",
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
]
},
"files": [
"public_api.ts",
"node_modules/zone.js/dist/zone.js.d.ts"
],
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "xivapi-client.js",
"flatModuleId": "@xivapi/angular-client"
}
}

0 comments on commit f251299

Please sign in to comment.