providers/.docs/content/5.api-reference/0.makeProviders.md

35 lines
986 B
Markdown
Raw Normal View History

2023-09-27 17:00:40 +00:00
# `makeProviders`
2023-12-29 15:59:30 +00:00
Make an instance of provider controls with configuration.
2023-12-31 03:35:48 +00:00
This is the main entry-point of the library. It is recommended to make one instance globally and reuse it throughout your application.
2023-09-27 17:00:40 +00:00
## Example
```ts
2023-12-29 16:47:49 +00:00
import { targets, makeProviders, makeDefaultFetcher } from '@movie-web/providers';
2023-09-27 17:00:40 +00:00
const providers = makeProviders({
fetcher: makeDefaultFetcher(fetch),
target: targets.NATIVE, // target native app streams
});
```
## Type
```ts
function makeProviders(ops: ProviderBuilderOptions): ProviderControls;
interface ProviderBuilderOptions {
// instance of a fetcher, all webrequests are made with the fetcher.
fetcher: Fetcher;
2023-12-31 03:35:48 +00:00
// instance of a fetcher, in case the request has CORS restrictions.
2023-09-27 17:00:40 +00:00
// this fetcher will be called instead of normal fetcher.
2023-12-31 03:35:48 +00:00
// if your environment doesn't have CORS restrictions (like Node.JS), there is no need to set this.
2023-09-27 17:00:40 +00:00
proxiedFetcher?: Fetcher;
// target to get streams for
target: Targets;
}
```