import express from "express" ; import { IConfig } from "../../../config" ; import { IRealm } from "../../../models/realm" ; export default ( { config , realm } ) : express . Router => { const app = express . Router ( ) ; app . get ( "/id" , ( _ , res ) => { res . contentType ( "html" ) ; res . send ( realm . generateClientId ( config . generateClientId ) ) ; } ) ; app . get ( "/peers" , ( _ , res ) => { if ( config . allow_discovery ) { const clientsIds = realm . getClientsIds ( ) ; return res . send ( clientsIds ) ; } res . sendStatus ( 401 ) ; } ) ; return app ; } ;