/** * @param {object} config configuration for the function return * @return {function} for calls */ const serve = options => { if (typeof options !== 'object') { throw new Error('Expecting options to be an object'); } const config = Object.assign({}, defaultOptions, options); if (!config.secret || config.secret === '') { throw new Error('You must provide the secret!'); } if (typeof config.cmd !== 'string' && typeof config.cmd !== 'function') { throw new Error('Cmd must be a string or a function!'); } debug(config); const createHandler = provider(config.provider); // Return without Promise, because there is no need to return createHandler( config, { env: Object.assign({}, process.env), cwd: config.dir ? config.dir : process.cwd() }, typeof config.cmd === 'function' ? config.cmd : createCallback(config.cmd.split(' ')) ); }