UNPKG

sync-server

Version:

A simple server which can be used to synchronize data from Dexie.Syncable and an ISyncProtocol implementation and write them into files

30 lines (27 loc) 696 B
const startPollServer = require('./poll/server'); const startSocketServer = require('./socket/server'); function startServer({ logger, syncHandler, settings, dataPath, }) { if (settings.protocol === 'http' || settings.protocol === 'https') { startPollServer({ logger, syncHandler: syncHandler.pollHandler, settings, dataPath, }); } else if (settings.protocol === 'ws' || settings.protocol === 'wss') { startSocketServer({ logger, syncHandler: syncHandler.socketHandler, settings, dataPath, }); } else { throw new Error(`Protocol: ${settings.protocol} not supported`); } } module.exports = startServer;