Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Provide a title to the process in `ps`
process.title = 'polly';
const Polly = require('@pollyjs/node-server');
const cli = require('commander');
const version = require('../package.json').version;
cli.name('polly').version(version, '-v, --version');
cli
.command('listen')
.alias('l')
.description('start the server and listen for requests')
.option('-H, --host ', 'host')
.option('-p, --port ', 'port number', Polly.Defaults.port)
.option(
'-n, --api-namespace ',
'api namespace',
Polly.Defaults.apiNamespace
)
.option(
'-d, --recordings-dir
cli
.command('listen')
.alias('l')
.description('start the server and listen for requests')
.option('-H, --host ', 'host')
.option('-p, --port ', 'port number', Polly.Defaults.port)
.option(
'-n, --api-namespace ',
'api namespace',
Polly.Defaults.apiNamespace
)
.option(
'-d, --recordings-dir
let config = {
enabled: env !== 'production',
server: {}
};
let configPath = path.join(this.root, 'config', 'polly.js');
if (fs.existsSync(configPath)) {
let configGenerator = require(configPath);
Object.assign(config, configGenerator(env));
}
config.server.recordingsDir = path.join(
this.root,
config.server.recordingsDir || Defaults.recordingsDir
);
return config;
},
.action(function(options) {
new Polly.Server(options).listen();
});
testemMiddleware(app) {
if (this._config.enabled) {
registerExpressAPI(app, this._config.server);
}
}
};