import { Global, Module } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { PLATFORM_PORTS, LocalDevPorts } from './platform-ports';
import { RealtimeTokenRestGuard } from './realtime-token.guard';

/**
 * Binds the platform ports (P1: the permissive in-service default), and registers the
 * realtime-delegation REST guard globally — a socket-scoped token must not drive REST on ANY
 * route, so it can't be per-controller (see realtime-token.guard).
 */
@Global()
@Module({
  providers: [
    { provide: PLATFORM_PORTS, useClass: LocalDevPorts },
    { provide: APP_GUARD, useClass: RealtimeTokenRestGuard },
  ],
  exports: [PLATFORM_PORTS],
})
export class PlatformModule {}
