import { NodeCG } from "nodecg-types/types/server" ; import { Result , emptySuccess , success , ServiceBundle , Logger } from "nodecg-io-core" ; import { Tiane } from "./tiane" ; interface TianeServiceConfig { address : string ; } export type TianeServiceClient = Tiane ; module . exports = ( nodecg ) => { new TianeService ( nodecg , "tiane" , __dirname , "../tiane-schema.json" ) . register ( ) ; } ; class TianeService extends ServiceBundle < TianeServiceConfig , TianeServiceClient > { async validateConfig ( config ) { ( await Tiane . connect ( config . address ) ) . close ( ) ; return emptySuccess ( ) ; } async createClient ( config , logger ) { logger . info ( "Connecting to TIANE..." ) ; const client = await Tiane . connect ( config . address ) ; logger . info ( "Successfully connected to TIANE." ) ; return success ( client ) ; } stopClient ( client , logger ) { client . close ( ) ; logger . info ( "Disconnected from TIANE." ) ; } removeHandlers ( client ) { client . removeAllListeners ( ) ; } }