diff --git a/src/api/services/provideServices.ts b/src/api/services/provideServices.ts deleted file mode 100644 index a89e111b..00000000 --- a/src/api/services/provideServices.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type Bottle from 'bottlejs'; -import { buildShlinkApiClient } from './ShlinkApiClientBuilder'; - -export const provideServices = (bottle: Bottle) => { - bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient'); -}; diff --git a/src/app/services/provideServices.ts b/src/app/services/provideServices.ts deleted file mode 100644 index 0d3e58b6..00000000 --- a/src/app/services/provideServices.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type Bottle from 'bottlejs'; -import { AppFactory } from '../App'; - -export const provideServices = (bottle: Bottle) => { - // Components - bottle.factory('App', AppFactory); -}; diff --git a/src/common/services/provideServices.ts b/src/common/services/provideServices.ts deleted file mode 100644 index 001bbe08..00000000 --- a/src/common/services/provideServices.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/fetch'; -import type Bottle from 'bottlejs'; -import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer'; -import { Home } from '../Home'; -import { ShlinkWebComponentContainerFactory } from '../ShlinkWebComponentContainer'; - -export const provideServices = (bottle: Bottle) => { - // Services - bottle.constant('window', window); - bottle.constant('console', console); - bottle.constant('fetch', window.fetch.bind(window)); - bottle.service('HttpClient', FetchHttpClient, 'fetch'); - - bottle.serviceFactory('Home', () => Home); - bottle.decorator('Home', withoutSelectedServer); - - bottle.factory('ShlinkWebComponentContainer', ShlinkWebComponentContainerFactory); -}; diff --git a/src/container/index.ts b/src/container/index.ts index 81b5828e..25102bcf 100644 --- a/src/container/index.ts +++ b/src/container/index.ts @@ -1,16 +1,56 @@ +import { useTimeoutToggle } from '@shlinkio/shlink-frontend-kit'; +import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/fetch'; import Bottle from 'bottlejs'; -import { provideServices as provideApiServices } from '../api/services/provideServices'; -import { provideServices as provideAppServices } from '../app/services/provideServices'; -import { provideServices as provideCommonServices } from '../common/services/provideServices'; -import { provideServices as provideServersServices } from '../servers/services/provideServices'; -import { provideServices as provideUtilsServices } from '../utils/services/provideServices'; +import { buildShlinkApiClient } from '../api/services/ShlinkApiClientBuilder'; +import { AppFactory } from '../app/App'; +import { Home } from '../common/Home'; +import { ShlinkWebComponentContainerFactory } from '../common/ShlinkWebComponentContainer'; +import { CreateServerFactory } from '../servers/CreateServer'; +import { ImportServersBtnFactory } from '../servers/helpers/ImportServersBtn'; +import { withoutSelectedServer } from '../servers/helpers/withoutSelectedServer'; +import { ManageServersFactory } from '../servers/ManageServers'; +import { ServersExporter } from '../servers/services/ServersExporter'; +import { ServersImporter } from '../servers/services/ServersImporter'; +import { csvToJson, jsonToCsv } from '../utils/helpers/csvjson'; +import { LocalStorage } from '../utils/services/LocalStorage'; +import { TagColorsStorage } from '../utils/services/TagColorsStorage'; const bottle = new Bottle(); export const { container } = bottle; -provideAppServices(bottle); -provideCommonServices(bottle); -provideApiServices(bottle); -provideServersServices(bottle); -provideUtilsServices(bottle); +bottle.constant('window', window); +bottle.constant('console', console); +bottle.constant('fetch', window.fetch.bind(window)); +bottle.service('HttpClient', FetchHttpClient, 'fetch'); + +bottle.constant('localStorage', window.localStorage); +bottle.service('Storage', LocalStorage, 'localStorage'); +bottle.service('TagColorsStorage', TagColorsStorage, 'Storage'); + +bottle.constant('csvToJson', csvToJson); +bottle.constant('jsonToCsv', jsonToCsv); + +bottle.serviceFactory('useTimeoutToggle', () => useTimeoutToggle); + +bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient'); + +// Components +bottle.factory('App', AppFactory); + +bottle.serviceFactory('Home', () => Home); +bottle.decorator('Home', withoutSelectedServer); + +bottle.factory('ShlinkWebComponentContainer', ShlinkWebComponentContainerFactory); + +bottle.factory('ManageServers', ManageServersFactory); +bottle.decorator('ManageServers', withoutSelectedServer); + +bottle.factory('CreateServer', CreateServerFactory); +bottle.decorator('CreateServer', withoutSelectedServer); + +bottle.factory('ImportServersBtn', ImportServersBtnFactory); + +// Services +bottle.service('ServersImporter', ServersImporter, 'csvToJson'); +bottle.service('ServersExporter', ServersExporter, 'Storage', 'window', 'jsonToCsv'); diff --git a/src/servers/services/provideServices.ts b/src/servers/services/provideServices.ts deleted file mode 100644 index bb54bfa9..00000000 --- a/src/servers/services/provideServices.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type Bottle from 'bottlejs'; -import { CreateServerFactory } from '../CreateServer'; -import { ImportServersBtnFactory } from '../helpers/ImportServersBtn'; -import { withoutSelectedServer } from '../helpers/withoutSelectedServer'; -import { ManageServersFactory } from '../ManageServers'; -import { ServersExporter } from './ServersExporter'; -import { ServersImporter } from './ServersImporter'; - -export const provideServices = (bottle: Bottle) => { - // Components - bottle.factory('ManageServers', ManageServersFactory); - bottle.decorator('ManageServers', withoutSelectedServer); - - bottle.factory('CreateServer', CreateServerFactory); - bottle.decorator('CreateServer', withoutSelectedServer); - - bottle.factory('ImportServersBtn', ImportServersBtnFactory); - - // Services - bottle.service('ServersImporter', ServersImporter, 'csvToJson'); - bottle.service('ServersExporter', ServersExporter, 'Storage', 'window', 'jsonToCsv'); -}; diff --git a/src/utils/services/provideServices.ts b/src/utils/services/provideServices.ts deleted file mode 100644 index 7c3920ef..00000000 --- a/src/utils/services/provideServices.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useTimeoutToggle } from '@shlinkio/shlink-frontend-kit'; -import type Bottle from 'bottlejs'; -import { csvToJson, jsonToCsv } from '../helpers/csvjson'; -import { LocalStorage } from './LocalStorage'; -import { TagColorsStorage } from './TagColorsStorage'; - -export const provideServices = (bottle: Bottle) => { - bottle.constant('localStorage', window.localStorage); - bottle.service('Storage', LocalStorage, 'localStorage'); - bottle.service('TagColorsStorage', TagColorsStorage, 'Storage'); - - bottle.constant('csvToJson', csvToJson); - bottle.constant('jsonToCsv', jsonToCsv); - - bottle.serviceFactory('useTimeoutToggle', () => useTimeoutToggle); -};