(refactor) move http service to core package

This commit is contained in:
Halit Aksoy 2024-06-18 00:36:35 +03:00
parent bef8f1d9e9
commit e198e0fdcf
5 changed files with 12 additions and 15 deletions

View File

@ -6,4 +6,5 @@ export * from './localization/index'
export * from './util/index'
export * from './animation/index'
export * from './factory/index'
export * from './viewmodel/index'
export * from './viewmodel/index'
export * from './service/index'

View File

@ -0,0 +1,3 @@
export interface HttpService {
get: (route: string) => Promise<Response>;
}

View File

@ -0,0 +1 @@
export * from './httpService'

View File

@ -1,8 +1,4 @@
import { server } from "../const/config";
export interface HttpService {
get: (route: string) => Promise<Response>;
}
import { HttpService } from "@mancala/core"
export class HttpServiceImpl implements HttpService {
public serverAdress: string;
@ -12,7 +8,7 @@ export class HttpServiceImpl implements HttpService {
}
public async get(route: string): Promise<Response> {
const url = server.serverAdress + route;
const url = this.serverAdress + route;
const requestOptions = {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
@ -20,4 +16,4 @@ export class HttpServiceImpl implements HttpService {
const response = await fetch(url, requestOptions);
return response;
}
}
}

View File

@ -1,8 +1,4 @@
import { server } from "../const/config";
export interface HttpService {
get: (route: string) => Promise<Response>;
}
import { HttpService } from "@mancala/core"
export class HttpServiceImpl implements HttpService {
public serverAdress: string;
@ -12,7 +8,7 @@ export class HttpServiceImpl implements HttpService {
}
public async get(route: string): Promise<Response> {
const url = server.serverAdress + route;
const url = this.serverAdress + route;
const requestOptions = {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
@ -20,4 +16,4 @@ export class HttpServiceImpl implements HttpService {
const response = await fetch(url, requestOptions);
return response;
}
}
}