Skip to content

Quick Start

Build a simple risk dashboard in 5 minutes.

Setup

First, create a new project and install the SDK:

bash
mkdir risk-dashboard && cd risk-dashboard
bun init -y
bun add @deiterate/sdk

Create the Dashboard

Create a file called dashboard.ts:

typescript
import { DeIterateClient } from '@deiterate/sdk';

const client = new DeIterateClient({
  apiKey: 'your-api-key',
  organizationId: 'your-org-id',
});

async function dashboard() {
  console.log('🔒 Risk Dashboard\n');
  console.log('='.repeat(50));

  // Fetch risks
  const risks = await client.risks.list();
  
  // Count by severity
  const bySeverity = {
    critical: 0,
    high: 0,
    medium: 0,
    low: 0,
  };
  
  for (const risk of risks.data) {
    const severity = risk.severity?.toLowerCase() || 'low';
    if (severity in bySeverity) {
      bySeverity[severity as keyof typeof bySeverity]++;
    }
  }
  
  console.log('\n📊 Risks by Severity:\n');
  console.log(`  🔴 Critical: ${bySeverity.critical}`);
  console.log(`  🟠 High:     ${bySeverity.high}`);
  console.log(`  🟡 Medium:   ${bySeverity.medium}`);
  console.log(`  🟢 Low:      ${bySeverity.low}`);
  console.log(`\n  Total: ${risks.data.length} risks`);

  // Fetch controls
  const controls = await client.controls.list();
  
  console.log('\n🛡️ Control Status:\n');
  console.log(`  Total Controls: ${controls.data.length}`);

  // Fetch compliance status
  const frameworks = await client.frameworks.list();
  
  console.log('\n📋 Frameworks:\n');
  for (const framework of frameworks.data.slice(0, 5)) {
    console.log(`  • ${framework.name}`);
  }
  
  console.log('\n' + '='.repeat(50));
  console.log('✅ Dashboard complete!');
}

dashboard().catch(console.error);

Run It

bash
bun run dashboard.ts

You should see output like:

🔒 Risk Dashboard

==================================================

📊 Risks by Severity:

  🔴 Critical: 2
  🟠 High:     5
  🟡 Medium:   12
  🟢 Low:      8

  Total: 27 risks

🛡️ Control Status:

  Total Controls: 45

📋 Frameworks:

  • ISO 27001:2022
  • SOC 2 Type II
  • NIST CSF
  • CIS Controls v8
  • Essential 8

==================================================
✅ Dashboard complete!

Add Real-time Updates

Extend the dashboard to watch for changes:

typescript
// Subscribe to risk updates
await client.webhooks.create({
  url: 'https://your-server.com/webhook',
  events: ['risk.created', 'risk.updated', 'risk.deleted'],
});

Next Steps

Released under the MIT License.