1.0.16 • Published 2 years ago

chatbot-ui-rdbms v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Chatbot UI Relational Database Management System Extension

This extension provides PostgreSQL, MySQL, MariaDB, and CockroachDB support to my custom version of Chatbot UI.

Installation

Step 1

Install the database extension with npm:

npm i chatbot-ui-rdbms@latest

Step 2

Install the corresponding database driver. See the corresponding drivers here.

Step 3

Update /utils/app/storage.ts to use the new database.

import { Database } from 'chatbot-ui-core';
import { ClientSideDatabase } from 'chatbot-ui-rdbms/client-side'; // <-----Update here

let database: Database | null = null;

export const getDatabase = async () => {
  if (database) {
    return database;
  } else {
    database = new ClientSideDatabase(); // <-----Update here
    await database.connect();
    return database;
  }
};

Step 4

Update /pages/api/storage/[endpoint].ts

import { ServerDatabase } from 'chatbot-ui-core';
import { ServerSideDatabase } from 'chatbot-ui-rdbms/server-side'; // <-----Update here

export default async function proxy(req: NextApiRequest, res: NextApiResponse) {
  const database: ServerDatabase = new ServerSideDatabase(); // <-----Update here
  ...

Configuration

Use the following env variables to configure your connection:

Environment VariableDefault valueDescription
RDBMS_DB_TYPEpostgresThe database type of the RDBMS instance
RDBMS_HOST127.0.0.1The hostname of the RDBMS instance
RDBMS_PORT5432The port of the RDBMS instance
RDBMS_DBpostgresThe database name of the RDBMS instance
RDBMS_USERpostgresThe username of the RDBMS instance
RDBMS_PASSpasswordThe password of the RDBMS instance
RDBMS_SYNCHRONIZEtrueWhether to create tables from entities. Should be false in production.
RDBMS_SSL_ENABLEDfalseWhether to require SSL to connect to the database.
RDBMS_SSL_HOSTThe hostname of the database server you are connecting to. Google Cloud may require this.
RDBMS_SSL_CAThe Server CA certificate used for SSL connections, in the form of a single line string.
RDBMS_SSL_CERTThe Client certificate used for SSL connections, in the form of a single line string.
RDBMS_SSL_KEYThe Client certificate key used for SSL connections, in the form of a single line string.
RDBMS_COCKROACHDB_TIME_TRAVEL_QUERIESfalseWether to user time travel queries features in CockroachDB
1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago