Here is the GitHub repository.

Quickstart

Prerequisites

Before you begin, make sure you have:

  1. A Fortress account
  2. Connection to your cloud account
  3. Your API token
  4. Your Organization ID

You can find your API token and Organization ID in the Fortress dashboard under the API Keys section.

Installation

Install the SDK using npm:

npm install fortress-backend-sdk

Get Started

import { Fortress } from "fortress-sdk";

// Initialize the client
const client = new Fortress(apiKey, organizationId);
const conn = client.conn;

// Create a new tenant
client.createTenant("tenant_name", "alias");

// Connect to the tenant
const client = client.connectTenant("tenant_name");
const client = client.client;

conn.query("CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(50))");
conn.query("INSERT INTO users (name) VALUES ('Alice')");
conn.query("SELECT * FROM users", (result) => {
  result.forEach((row) => {
    console.log(`User: ${row["name"]}`);
  });
});

// Delete the tenant
conn.deleteTenant("tenant_name");