TypeScript SDK

Perfect for Express, NestJS, Next.js, and Vercel Edge functions. The SDK is designed to be entirely non-blocking, handling in-memory batching automatically.

Installation

(Assuming published to npm)

npm install @astralog/sdk

Usage

import { AstraLogClient } from '@astralog/sdk';

// Initialize once globally
const logger = new AstraLogClient({
  endpoint: process.env.ASTRALOG_ENDPOINT || 'http://localhost:8080/v1/drain',
  authToken: process.env.ASTRALOG_TOKEN || 'default-secret-token',
  projectId: 'my-startup',
  service: 'payment-api',
  maxBatchSize: 100,     // Optional: Flushes when 100 logs are reached
  flushIntervalMs: 5000  // Optional: Flushes every 5 seconds regardless of size
});

// Use throughout your app
logger.info("Payment successful", { amount: 150.00, currency: "USD" });
logger.error("Database connection failed", { db_host: "10.0.0.5" });

// Graceful Shutdown: Ensure logs are flushed before process exit
process.on('SIGTERM', async () => {
  await logger.close();
  process.exit(0);
});