import { NodeCG } from "nodecg-types/types/server" ; import { Result , emptySuccess , success , ServiceBundle } from "nodecg-io-core" ; import { ShlinkClient } from "shlink-client" ; interface ShlinkServiceConfig { url : string ; apiKey : string ; } export type ShlinkServiceClient = ShlinkClient ; module . exports = ( nodecg ) => { new ShlinkService ( nodecg , "shlink" , __dirname , "../shlink-schema.json" ) . register ( ) ; } ; class ShlinkService extends ServiceBundle < ShlinkServiceConfig , ShlinkServiceClient > { async validateConfig ( config ) { const client = new ShlinkClient ( { url : config . url , token : config . apiKey } ) ; await client . countVisits ( ) ; return emptySuccess ( ) ; } async createClient ( config ) { const client = new ShlinkClient ( { url : config . url , token : config . apiKey } ) ; return success ( client ) ; } stopClient ( _client ) { } }