new GatewayManager(clientKey, clientSecret)
Creates a new instance of the constructor.
Parameters:
Name | Type | Description |
---|---|---|
clientKey | string | The access key ID for authentication. |
clientSecret | string | The secret access key for authentication. |
- Source
- Tutorials
Example
import { GatewayManager } from "@filebase/sdk";
const gatewayManager = new GatewayManager("KEY_FROM_DASHBOARD", "SECRET_FROM_DASHBOARD");
Methods
(async) create(name, optionsopt) → {Promise.<gateway>}
Creates a gateway with the given name and options
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name | string | Unique name across entire platform for the gateway. Must be a valid subdomain name. | |
options | gatewayOptions | <optional> |
- Source
Returns:
- A promise that resolves to the value of a gateway.
- Type:
- Promise.<gateway>
Example
// Create gateway with name of `create-gateway-example` and a custom domain of `cname.mycustomdomain.com`.
// The custom domain must already exist and have a CNAME record pointed at `create-gateway-example.myfilebase.com`.
await gatewayManager.create(`create-gateway-example`, {
domain: `cname.mycustomdomain.com`
});
(async) delete(name) → {Promise.<boolean>}
Deletes a gateway with the given name.
Parameters:
Name | Type | Description |
---|---|---|
name | string | The name of the gateway to delete. |
- Source
Returns:
- A promise that resolves to true if the gateway was successfully deleted.
- Type:
- Promise.<boolean>
Example
// Delete gateway with name of `delete-gateway-example`
await gatewayManager.delete(`delete-name-example`);
(async) get(name) → {Promise.<(gateway|false)>}
Returns the value of a gateway
Parameters:
Name | Type | Description |
---|---|---|
name | string | Parameter representing the name to get. |
- Source
Returns:
- A promise that resolves to the value of a gateway.
- Type:
- Promise.<(gateway|false)>
Example
// Get gateway with name of `gateway-get-example`
await gatewayManager.get(`gateway-get-example`);
(async) list() → {Promise.<Array.<gateway>>}
Returns a list of gateways
- Source
Returns:
- A promise that resolves to an array of gateways.
- Type:
- Promise.<Array.<gateway>>
Example
// List all gateways
await gatewayManager.list();
(async) update(name, options) → {Promise.<boolean>}
Updates the specified gateway.
Parameters:
Name | Type | Description |
---|---|---|
name | string | The name of the gateway to update. |
options | gatewayOptions | The options for the update operation. |
- Source
Returns:
- A Promise that resolves to true if the gateway was updated.
- Type:
- Promise.<boolean>
Example
// Update gateway with name of `update-gateway-example` and set the gateway to only serve CIDs pinned by user.
await gatewayManager.update(`update-gateway-example`, {
private: true
});
(async) toggle(name, targetState) → {Promise.<boolean>}
Toggles the enabled state of a given gateway.
Parameters:
Name | Type | Description |
---|---|---|
name | string | The name of the gateway to toggle. |
targetState | boolean | The new target state. |
- Source
Returns:
A promise that resolves to true if the gateway was successfully toggled.
- Type:
- Promise.<boolean>
Example
// Toggle gateway with label of `toggle-gateway-example`
await gatewayManager.toggle(`toggle-gateway-example`, true); // Enabled
await gatewayManager.toggle(`toggle-gateway-example`, false); // Disabled