1.0.16 • Published 2 years ago
chatbot-ui-rdbms v1.0.16
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 Variable | Default value | Description |
---|---|---|
RDBMS_DB_TYPE | postgres | The database type of the RDBMS instance |
RDBMS_HOST | 127.0.0.1 | The hostname of the RDBMS instance |
RDBMS_PORT | 5432 | The port of the RDBMS instance |
RDBMS_DB | postgres | The database name of the RDBMS instance |
RDBMS_USER | postgres | The username of the RDBMS instance |
RDBMS_PASS | password | The password of the RDBMS instance |
RDBMS_SYNCHRONIZE | true | Whether to create tables from entities. Should be false in production. |
RDBMS_SSL_ENABLED | false | Whether to require SSL to connect to the database. |
RDBMS_SSL_HOST | The hostname of the database server you are connecting to. Google Cloud may require this. | |
RDBMS_SSL_CA | The Server CA certificate used for SSL connections, in the form of a single line string. | |
RDBMS_SSL_CERT | The Client certificate used for SSL connections, in the form of a single line string. | |
RDBMS_SSL_KEY | The Client certificate key used for SSL connections, in the form of a single line string. | |
RDBMS_COCKROACHDB_TIME_TRAVEL_QUERIES | false | Wether to user time travel queries features in CockroachDB |