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
tenantwith partition keytenantName
bash
npx nx test tenant-nodeRecommended way to run DynamoDB Local is through NoSQL Workbench.