Yml Settings
π§βπ³ api.yml
Introduction
The api.yml
file is essential for configuring API adapters, specifically for the Directus SDK API and the Fetch API. You can define multiple adapters within this file to suit your application's needs.
Overview
This section provides a detailed breakdown of the components within the api.yml
file, explaining how the internal @tanglemedia packages utilize this configuration.
Here is an example of the api.yml file:
Default Adapter
The Default value serves as a fallback for the @tanglemedia/svelte-starter-core package. If you do not specify an API adapter key when resolving the adapter configuration, this default will be used.
Adapters
The Adapters section contains all your API adapter configurations. This allows for multiple adapters, each with different configurations, names, and actions. Currently, two primary types of adapters are supported:
- Fetch Adapter: For standard REST API calls, typically used with a PHP/Laravel backend.
- Directus Adapter: Specifically designed for use with Directus SDK.
Fetch Adapters
The Fetch Adapters configuration is intended for standard REST API calls. Hereβs what you need to know:
BaseURL
- Description: [To Be Determined]
Configuration
- Description: [To Be Determined]
Directus Adapters
The Directus Adapters are tailored for Directus SDK interactions. Below are the key configurations:
Adapter Key
- Description: This key is generally consistent across all your Directus adapters and often matches your default value.
Configuration Options
host
: Your Directus backend URL.protocol
: The protocol used for your Directus backend (e.g.,http
orhttps
).auth.mode
: The authorization mode (e.g.,json
orcookie
), defaulting tojson
. This determines how authorization payload information is sent from the server to your application.auth.config.storage
: The storage mode for your authentication data (e.g.,localStorage
,cookie
, orsessions
), withlocalStorage
as the default.auth.config.autoRefresh
: A boolean indicating whether the API should automatically call the refresh endpoint periodically, based on your settings.auth.config.msRefreshBeforeExpires
: The interval (in milliseconds) for calling the refresh API, defaulting to30000
.auth.config.credentials
: This option specifies whether to include credentials in your API calls, defaulting toinclude
.
Conclusion
By organizing your API adapters within the api.yml
file, you can effectively manage interactions with different backend services. Ensure to configure each adapter according to your application's requirements for optimal functionality.