Skip to content

@collectivtech/alana-sdk-js


@collectivtech/alana-sdk-js / server / AlanaServerApi

Class: AlanaServerApi ​

Defined in: src/server.ts:13

Constructors ​

Constructor ​

new AlanaServerApi(options, secretKey): AlanaServerApi

Defined in: src/server.ts:65

Create a new entry point for ALANA API protected routes. This also initializes all resource classes using a shared context.

Note that the apiKey property of the options object is ignored. For non-protected routes, continue using an AlanaApi SDK instance.

Also, because of the potentially destructive nature of the server API, the mode for this SDK class defaults to development, not production.

If an AlanaServerApi instance is created in a browser environment, a console warning will be issued in non-production modes, reminding you that these APIs are intended to be used in a full-stack environment, not somewhere that exposes your secret key. In production, this warning is upgraded to an error that halts creation of the Server SDK instance.

Parameters ​

options ​

SdkOptions

Global options that will be added to all API calls

secretKey ​

string

Returns ​

AlanaServerApi

Properties ​

Businesses ​

Businesses: Businesses

Defined in: src/server.ts:19

The resource class for businesses on the ALANA Platform.


Coins ​

Coins: Coins

Defined in: src/server.ts:24

The resource class for ALANA Platform Coins.


Experiences ​

Experiences: Experiences

Defined in: src/server.ts:29

The resource class for experiences and other activities.


Memberships ​

Memberships: Memberships

Defined in: src/server.ts:34

The resource class for memberships and subscriptions.


Plugins ​

Plugins: Plugins

Defined in: src/server.ts:45

A resource class to serve as a plugin registry.


Products ​

Products: Products

Defined in: src/server.ts:40

The resource class for products and services that may be purchased through the ALANA Platform.

Methods ​

clearTokens() ​

clearTokens(): boolean

Defined in: src/server.ts:175

Remove an existing set of authentication tokens from this SDK instance, without logging out the active user. This may be needed for some advanced use cases in multi-page applications.

Returns ​

boolean

true if the operation succeeded


rawApi() ​

rawApi(route, options?): Promise<any>

Defined in: src/server.ts:131

Make a "raw" call to the API. This is not associated with any resource, but only interacts with the ALANA Platform as if using a raw fetch call.

Parameters ​

route ​

string

The URL of the route to call, not including any query parameters

options? ​

any

Any options for the API call, such as HTTP method, query or body parameters, additional headers, etc.

Returns ​

Promise<any>

The raw response from the ALANA Platform API


setTokens() ​

setTokens(tokens): boolean

Defined in: src/server.ts:160

Attach a set of authentication tokens to this SDK instance. This is necessary for multi-page apps and other use cases where the same login credentials are needed, but different SDK instances are being used.

Parameters ​

tokens ​

TokenResponse

A set of API authentication tokens

Returns ​

boolean

true if the operation succeeded


setTokensFromSdk() ​

setTokensFromSdk(sdkInstance): void

Defined in: src/server.ts:142

Attach a set of authentication tokens taken from an Alana SDK instance. This merely copies the tokens a single time; it does not keep them updated.

Parameters ​

sdkInstance ​

AlanaApi

An AlanaApi SDK instance

Returns ​

void

ALANA™, ALANA Platform™, ALANA Guide™, and ALANA Partner™ are trademarks of Collectiv Technologies Inc.