diff --git a/declaration.d.ts b/declaration.d.ts index 0292a33..92bdf7d 100644 --- a/declaration.d.ts +++ b/declaration.d.ts @@ -1 +1,9 @@ declare module "*.scss"; +declare var __CONFIG__: SettingType; + +type SettingType = { + apiUrl: string; + apiVersion: string; + ssl: string; + appName: string; +}; diff --git a/src/components/app-menu/AppMenuElement.ts b/src/components/app-menu/AppMenuElement.ts index e4a6c12..a3bd451 100644 --- a/src/components/app-menu/AppMenuElement.ts +++ b/src/components/app-menu/AppMenuElement.ts @@ -132,7 +132,7 @@ class AppMenuElement extends BaseComponentElement { return html`
- ${menuHeader("Wallets")} ${regularMenu("/", "Home")} + ${menuHeader(__CONFIG__.appName)} ${regularMenu("/", "Home")} ${authMenu("/history", "Transaction History")} ${authMenu( "/wallet/all", diff --git a/src/configs/development/app-settings.json b/src/configs/development/app-settings.json index 1a74f7a..b8b1613 100644 --- a/src/configs/development/app-settings.json +++ b/src/configs/development/app-settings.json @@ -1,5 +1,6 @@ { - "apiUrl": "main-wallet--dtnyc2vcdgu2re9j-gtw.qovery.io", + "apiUrl": "localhost:4000", "apiVersion": "v1", - "ssl": true + "ssl": false, + "appName": "Wallets" } \ No newline at end of file diff --git a/src/core/services/http-service/HttpClient.ts b/src/core/services/http-service/HttpClient.ts index 4bfe777..a4db320 100644 --- a/src/core/services/http-service/HttpClient.ts +++ b/src/core/services/http-service/HttpClient.ts @@ -1,11 +1,9 @@ -import settings from "configs/development/app-settings.json"; - class HttpClient { private url: string; constructor() { - this.url = `${settings.ssl ? "https" : "http"}://${settings.apiUrl}/${ - settings.apiVersion - }`; + this.url = `${__CONFIG__.ssl ? "https" : "http"}://${ + __CONFIG__.apiUrl + }/${__CONFIG__.apiVersion}`; } post(url: string, data: Object, headersParam: HeadersInit): Promise { diff --git a/webpack.config.js b/webpack.config.js index d4345d5..16282f7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,7 @@ const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const settings = require("./src/configs/development/app-settings.json"); +const { DefinePlugin } = require('webpack'); const alias = { common: path.resolve(__dirname, '/common'), @@ -83,6 +85,9 @@ module.exports = { new HtmlWebpackPlugin({ template: './src/index.html' }), + new DefinePlugin({ + __CONFIG__: JSON.stringify(settings) + }) ], resolve: { extensions: ['.js', '.ts'],