Skip to content

Add TypeScript type definitions for Node.js #9

Description

@thatsjet

Summary

TypeScript adoption is >60% in the Node.js ecosystem. Adding type definitions significantly improves adoption and developer experience.

Instructions

Create nodejs/security_event_logger.d.ts

interface EventDefinition {
  category: string;
  prefix: string;
  level: 'INFO' | 'WARN' | 'CRITICAL';
  description: string;
  parameters: string[];
}

interface LogEventOptions {
  description?: string;
  useragent?: string;
  source_ip?: string;
  host_ip?: string;
  hostname?: string;
  protocol?: string;
  port?: string;
  request_uri?: string;
  request_method?: string;
  region?: string;
  geo?: string;
  [key: string]: string | undefined;
}

interface LogEntry {
  datetime: string;
  appid: string;
  event: string;
  level: string;
  description: string;
  [key: string]: string;
}

declare class SecurityEventLogger {
  constructor(appid: string, eventsFile?: string | null);
  logEvent(eventType: string, params?: string[], options?: LogEventOptions): LogEntry;
  getEventInfo(eventType: string): EventDefinition;
  listEvents(category?: string | null): string[];
}

export = SecurityEventLogger;

Update nodejs/package.json

Add: "types": "security_event_logger.d.ts"

Verification

  • Create a test TypeScript file that imports and uses the logger
  • tsc --noEmit test.ts compiles without errors
  • Type definitions match the actual runtime API

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Nice to have — improves adoptionenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions