-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from sima-land/38-examples-bun
Шаг 71 #38
- Loading branch information
Showing
14 changed files
with
113 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Провайдер AbortController. | ||
* @return AbortController. | ||
*/ | ||
export function provideAbortController(): AbortController { | ||
return new AbortController(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
import { CreateAxiosDefaults } from 'axios'; | ||
import { create } from 'middleware-axios'; | ||
|
||
/** | ||
* Провайдер фабрики экземпляров AxiosInstanceWrapper. | ||
* @param resolve Функция для получения зависимости по токену. | ||
* @return Фабрика. | ||
*/ | ||
export function provideAxiosFactory(resolve: Resolve) { | ||
const middleware = resolve(KnownToken.Axios.middleware); | ||
|
||
return (config: CreateAxiosDefaults = {}) => { | ||
const instance = create(config); | ||
|
||
for (const item of middleware) { | ||
instance.use(item); | ||
} | ||
|
||
return instance; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Resolve } from '../../../di'; | ||
import { LogMiddlewareHandlerInit } from '../../../utils/axios/middleware/log'; | ||
import { KnownToken } from '../../../tokens'; | ||
import { AxiosLogging } from '../utils/axios-logging'; | ||
|
||
/** | ||
* Провайдер обработчика логирования исходящих http-запросов. | ||
* @param resolve Функция для получения зависимости по токену. | ||
* @return Обработчик. | ||
*/ | ||
export function provideAxiosLogHandler(resolve: Resolve): LogMiddlewareHandlerInit { | ||
const logger = resolve(KnownToken.logger); | ||
|
||
return data => new AxiosLogging(logger, data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createBaseConfig } from '../../../config/base'; | ||
import { BaseConfig } from '../../../config/types'; | ||
import { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
|
||
/** | ||
* Провайдер базовой конфигурации приложения. | ||
* @param resolve Функция для получения зависимости по токену. | ||
* @return Базовая конфигурация. | ||
*/ | ||
export function provideBaseConfig(resolve: Resolve): BaseConfig { | ||
const source = resolve(KnownToken.Config.source); | ||
|
||
return createBaseConfig(source); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
import { applyMiddleware, configureFetch } from '../../../http'; | ||
|
||
/** | ||
* Провайдер функции fetch. | ||
* @param resolve Функция для получения зависимости по токену. | ||
* @return Функция fetch. | ||
*/ | ||
export function provideFetch(resolve: Resolve) { | ||
const middleware = resolve(KnownToken.Http.Fetch.middleware); | ||
|
||
return configureFetch(fetch, applyMiddleware(...middleware)); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
import { SagaLogging } from '../utils/saga-logging'; | ||
import createSagaMiddleware, { SagaMiddleware } from 'redux-saga'; | ||
|
||
/** | ||
* Провайдер промежуточного слоя redux-saga для redux-хранилища. | ||
* @param resolve Функция для получения зависимости по токену. | ||
* @return Промежуточный слой для redux-хранилища. | ||
*/ | ||
export function provideReduxMiddlewareSaga(resolve: Resolve): SagaMiddleware { | ||
const logger = resolve(KnownToken.logger); | ||
|
||
const logHandler = new SagaLogging(logger); | ||
|
||
return createSagaMiddleware({ | ||
/** @inheritdoc */ | ||
onError(error, errorInfo) { | ||
logHandler.onSagaError(error, errorInfo); | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters