GatewayManager

new GatewayManager(clientKey, clientSecret)

Creates a new instance of the constructor.

Parameters:
NameTypeDescription
clientKeystring

The access key ID for authentication.

clientSecretstring

The secret access key for authentication.

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:
NameTypeAttributesDescription
namestring

Unique name across entire platform for the gateway. Must be a valid subdomain name.

optionsgatewayOptions<optional>
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:
NameTypeDescription
namestring

The name of the gateway to delete.

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:
NameTypeDescription
namestring

Parameter representing the name to get.

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

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:
NameTypeDescription
namestring

The name of the gateway to update.

optionsgatewayOptions

The options for the update operation.

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:
NameTypeDescription
namestring

The name of the gateway to toggle.

targetStateboolean

The new target state.

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