import { Config } from './core/config' ; import login from './session' ; import { addLogRotate } from './core/logging' ; import { IgApiClient } from 'instagram-private-api' ; import fs from 'fs' ; import { liked$ } from './streams/like' ; import { store } from './core/store' ; function setupClient ( config ) { addLogRotate ( config . workspacePath ) ; if ( ! fs . existsSync ( config . workspacePath ) ) fs . mkdirSync ( config . workspacePath ) ; if ( ! config . seed ) config . seed = config . username ; const client = new IgApiClient ( ) ; if ( config . proxy ) client . state . proxyUrl = config . proxy ; return client ; } async function setup ( config ) { const client = setupClient ( config ) ; await login ( client , config ) ; store . setState ( { config , client } ) ; liked$ . subscribe ( ) ; return client ; } export default setup ;