api url is added

This commit is contained in:
병준 박 2019-08-17 21:54:21 +09:00
parent cd76913035
commit 94efeb43fd
5 changed files with 30 additions and 36 deletions

View File

@ -3,15 +3,13 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { UserModule } from './pages/users/user/user.module';
import { AppService } from './service/app.service';
import { API_BASE_URL } from 'src/shared/common/type/injection-token.type';
export function initApp(appService: AppService) {
return () => appService.initApp();
}
@NgModule({
imports: [
UserModule.forRoot(),
],
imports: [UserModule.forRoot()],
exports: [],
providers: [
AppService,
@ -24,6 +22,11 @@ export function initApp(appService: AppService) {
deps: [AppService],
multi: true
},
{
provide: API_BASE_URL,
useValue: 'http://localhost:8088/api',
multi: true
},
// { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true },
{ provide: 'virtualScroller.scrollThrottlingTime', useValue: 0 },
{ provide: 'virtualScroller.scrollDebounceTime', useValue: 0 },

View File

@ -2,8 +2,6 @@ import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { COMPONENTS } from './component';
import { AccountsService } from './service/accounts.service';
import { AccountsStoreModule } from './accounts-store.module';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
@ -14,7 +12,14 @@ import { MatInputModule } from '@angular/material/input';
import { FuseSharedModule } from 'src/@fuse/shared.module';
import { AccountsRoutingPageModule } from './accounts-routing.page.module';
// import { SharedModule } from '../../../common/shared/shared.module';
import { COMPONENTS } from './component';
import { SERVICES } from './service';
@NgModule({
imports: [AccountsStoreModule],
exports: []
})
export class AccountsRootModule {}
@NgModule({
imports: [
@ -31,32 +36,15 @@ import { AccountsRoutingPageModule } from './accounts-routing.page.module';
FuseSharedModule
// SharedModule,
],
declarations: [
...COMPONENTS,
],
exports: [
...COMPONENTS,
],
declarations: [...COMPONENTS],
exports: [...COMPONENTS]
})
export class AccountsModule {
public static forRoot(): ModuleWithProviders<AccountsRootModule> {
return {
ngModule: AccountsRootModule,
providers: [
AccountsService,
],
providers: [...SERVICES]
};
}
}
@NgModule({
imports: [
AccountsStoreModule,
],
exports: [
]
})
export class AccountsRootModule {
}

View File

@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@ -7,14 +7,15 @@ import { map } from 'rxjs/operators';
import { CookieService } from 'ngx-cookie-service';
import { environment } from '../../../../environments/environment';
import { User } from '../../../../shared/user/model/user.model';
import { API_BASE_URL } from 'src/shared/common/type/injection-token.type';
@Injectable()
export class AccountsService {
public constructor(
private httpClient: HttpClient,
private cookieService: CookieService,
) {
}
@Inject(API_BASE_URL) private apiBaseUrl: string
) {}
// public authenticate(oauthType: string, params?: Map<string, string>) {
// const query = this.getQueryParams(params);
@ -40,7 +41,6 @@ export class AccountsService {
let query = '';
if (!params || 0 === params.size) {
model
return query;
}
@ -60,9 +60,6 @@ export class AccountsService {
password
};
return this.httpClient.post<User>(
`${this.apiEntryPoint}/auth/signin`,
model
);
return this.httpClient.post<User>(`${this.apiBaseUrl}/auth/signin`, model);
}
}

View File

@ -0,0 +1,3 @@
import { AccountsService } from './accounts.service';
export const SERVICES = [AccountsService];

View File

@ -0,0 +1,3 @@
import { InjectionToken } from '@angular/core';
export const API_BASE_URL = new InjectionToken<string>('API_BASE_URL');