Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fs = require('fs')
const path = require('path')
const throttle = require('lodash/throttle')
const logger = require('electron-timber')
const randombytes = require('randombytes')
const os = require('os')
const MapeoCore = require('@mapeo/core')
const sublevel = require('subleveldown')
const createMapeoServer = require('./main/server')
const installStatsIndex = require('./main/osm-stats')
const userConfig = require('./main/user-config')
const errors = MapeoCore.errors
const expectedMediaFormats = ['original', 'preview', 'thumbnail']
class MapeoRPC {
constructor (datadir, ipcSend) {
// TODO: bind all the things since they're being passed
// around a lot to various event listeners...
this.mapeo = createMapeo(datadir)
this.ipcSend = ipcSend
this.ipcSend('indexes-loading')
this.mapeo.osm.ready(() => {
logger.log('indexes READY')
this.ipcSend('indexes-ready')
})
// Sending data over IPC is costly, and progress events fire frequently, so we