From e198e0fdcf9b15f75257ae08913d361f2b920a47 Mon Sep 17 00:00:00 2001 From: Halit Aksoy Date: Tue, 18 Jun 2024 00:36:35 +0300 Subject: [PATCH] (refactor) move http service to core package --- core/src/index.ts | 3 ++- core/src/service/httpService.ts | 3 +++ core/src/service/index.ts | 1 + frontend/src/service/HttpService.ts | 10 +++------- mobile/src/service/HttpService.ts | 10 +++------- 5 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 core/src/service/httpService.ts create mode 100644 core/src/service/index.ts diff --git a/core/src/index.ts b/core/src/index.ts index 7fe4bd6..977d591 100644 --- a/core/src/index.ts +++ b/core/src/index.ts @@ -6,4 +6,5 @@ export * from './localization/index' export * from './util/index' export * from './animation/index' export * from './factory/index' -export * from './viewmodel/index' \ No newline at end of file +export * from './viewmodel/index' +export * from './service/index' \ No newline at end of file diff --git a/core/src/service/httpService.ts b/core/src/service/httpService.ts new file mode 100644 index 0000000..9c8f2d0 --- /dev/null +++ b/core/src/service/httpService.ts @@ -0,0 +1,3 @@ +export interface HttpService { + get: (route: string) => Promise; +} diff --git a/core/src/service/index.ts b/core/src/service/index.ts new file mode 100644 index 0000000..823f652 --- /dev/null +++ b/core/src/service/index.ts @@ -0,0 +1 @@ +export * from './httpService' \ No newline at end of file diff --git a/frontend/src/service/HttpService.ts b/frontend/src/service/HttpService.ts index c07c2f7..026638c 100644 --- a/frontend/src/service/HttpService.ts +++ b/frontend/src/service/HttpService.ts @@ -1,8 +1,4 @@ -import { server } from "../const/config"; - -export interface HttpService { - get: (route: string) => Promise; -} +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 { - 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; } -} +} \ No newline at end of file diff --git a/mobile/src/service/HttpService.ts b/mobile/src/service/HttpService.ts index c07c2f7..026638c 100644 --- a/mobile/src/service/HttpService.ts +++ b/mobile/src/service/HttpService.ts @@ -1,8 +1,4 @@ -import { server } from "../const/config"; - -export interface HttpService { - get: (route: string) => Promise; -} +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 { - 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; } -} +} \ No newline at end of file