Skip to content

Tenant Node Library

typescript
import { Tenant, getInstance, create } from '@kmp/tenant-mode';

const tableName = process.env{'TENANT_TABLE_NAME'] || 'tenant';
const { docClient, tableName } = getInstance({tableName});

const item: Tenant = {
  tenantName: 'footenant',
  userName: 'foo',
  status: 'pending'
};

const response = await create({docClient, tableName, item});

if (!response.success) {
  console.log('Error:', response.err)
}

Testing

  • Run DynamoDB Local on localhost:8000
  • Create a table named tenant with partition key tenantName
bash
npx nx test tenant-node

Recommended way to run DynamoDB Local is through NoSQL Workbench.

Made with ❤️ by Bagubagu Studio