UNPKG

ipfsd-ctl

Version:
42 lines 1.15 kB
import DefaultFactory from './factory.js'; import Server from './endpoint/server.js'; /** * Creates a factory * * @param {ControllerOptions} [options] * @param {ControllerOptionsOverrides} [overrides] * @returns {Factory} */ export const createFactory = (options, overrides) => { return new DefaultFactory(options, overrides); }; /** * Creates a node */ export const createController = async (options) => { const f = new DefaultFactory(); return await f.spawn(options); }; /** * Create a Endpoint Server * * @param {number | { port: number }} [options] - Configuration options or just the port. * @param {ControllerOptions} [factoryOptions] * @param {ControllerOptionsOverrides} [factoryOverrides] */ export const createServer = (options, factoryOptions = {}, factoryOverrides = {}) => { let port; if (typeof options === 'number') { port = options; } else if (options != null) { port = options.port; } return new Server({ port, host: '127.0.0.1' }, () => { return createFactory(factoryOptions, factoryOverrides); }); }; //# sourceMappingURL=index.js.map