@niledatabase/server
TypeScript icon, indicating that this package has built-in type declarations

2.4.2-alpha.3 • Public • Published

@niledatabase/server

Consolidates the API and DB for working with Nile.

Usage

With configuration object

import Nile from '@niledatabase/server';

const nile = await Nile({
  user: 'username',
  password: 'password',
});

await nile.api.createTenant({ name: 'name' });

await nile.db.query('select * from todo');

With env vars

NILEDB_USER=username
NILEDB_PASSWORD=password
import Nile from '@niledatabase/server';

const nile = await Nile();

await nile.api.createTenant({ name: 'name' });

await nile.db.query('select * from todo');

Initialization

In addition to user and password, a fully configured SDK must also have values for db.host, databaseName, and databaseId. If the values are not provided in either the .env file or the instance configuration, the init() function should be called, which will allow the SDK to automatically configure itself. For production, it is recommended to set those values.

Configuration

Configuration passed to Server takes precedence over .env vars.

Property Type .env var Description
user string NILEDB_USER Required. Username for database authentication.
password string NILEDB_PASSWORD Required. Password for database authentication.
databaseId string NILEDB_ID ID of the database.
databaseName string NILEDB_NAME Name of the database.
tenantId string NILEDB_TENANT ID of the tenant associated.
userId string ID of the user associated.
db PoolConfig Configuration object for pg.Pool.
db.host string NILEDB_HOST Base host for DB. Defaut is db.thenile.dev
api object Configuration object for API settings.
api.basePath string NILEDB_API_URL Base host for API for a specific region.
api.cookieKey string Key for API cookie. Default is token.
api.token string NILEDB_TOKEN Token for API authentication. Mostly for debugging.
debug boolean Flag for enabling debug logging.

Readme

Keywords

none

Package Sidebar

Install

npm i @niledatabase/server

Weekly Downloads

211

Version

2.4.2-alpha.3

License

MIT

Unpacked Size

568 kB

Total Files

30

Last publish

Collaborators

  • gwenshap
  • nifedatabase-user