Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function multipartBodyParser(options) {
if (!options) {
options = {};
}
assert.object(options, 'options');
assert.optionalBool(options.overrideParams, 'options.overrideParams');
assert.optionalBool(options.multiples, 'options.multiples');
assert.optionalBool(options.keepExtensions, 'options.keepExtensions');
assert.optionalString(options.uploadDir, 'options.uploadDir');
assert.optionalNumber(options.maxFieldsSize, 'options.maxFieldsSize');
assert.optionalString(options.hash, 'options.hash');
assert.optionalFunc(options.multipartFileHandler,
'options.multipartFileHandler');
assert.optionalFunc(options.multipartHandler, 'options.multipartHandler');
assert.optionalBool(options.mapParams, 'options.mapParams');
assert.optionalBool(options.mapFiles, 'options.mapFiles');
var override = options.overrideParams;
function parseMultipartBody(req, res, next) {
next = once(next);
if (req.getContentType() !== 'multipart/form-data' ||
(req.getContentLength() === 0 && !req.isChunked())) {
return (next());
}
var form = new formidable.IncomingForm();
// enable multiple files on a single upload field
function HttpClient(options) {
assert.object(options, 'options');
assert.optionalObject(options.headers, 'options.headers');
assert.object(options.log, 'options.log');
assert.optionalFunc(options.signRequest, 'options.signRequest');
assert.optionalString(options.socketPath, 'options.socketPath');
assert.optionalString(options.url, 'options.url');
EventEmitter.call(this);
var self = this;
this.agent = options.agent;
this.ca = options.ca;
this.cert = options.cert;
this.ciphers = options.ciphers;
this.connectTimeout = options.connectTimeout || false;
this.headers = options.headers || {};
this.log = options.log;
if (!this.log.serializers || !this.log.serializers.client_res) {
// Ensure logger has a reasonable serializer for `client_res`
function IMGAPI(options) {
assert.object(options, 'options');
assert.string(options.url, 'options.url');
assert.optionalString(options.channel, 'options.channel');
assert.optionalString(options.user, 'options.user');
assert.optionalString(options.password, 'options.password');
assert.optionalFunc(options.sign, 'options.sign');
assert.ok(!(options.password && options.sign),
'not both "options.password" and "options.sign"');
if (options.version) {
// Allow options.version=null to avoid default, mainly for testing.
assert.string(options.version, 'options.version');
}
options = objCopy(options);
// `this.url` is the URL with the optional channel query param *removed*.
var parsed = mod_url.parse(options.url);
if (parsed.query) {
var params = qs.parse(parsed.query);
if (params.channel) {
this.channel = params.channel;
}
delete parsed.search;
function multipartBodyParser(options) {
var opts = options || {};
assert.object(opts, 'opts');
assert.optionalBool(opts.overrideParams, 'opts.overrideParams');
assert.optionalBool(opts.multiples, 'opts.multiples');
assert.optionalBool(opts.keepExtensions, 'opts.keepExtensions');
assert.optionalString(opts.uploadDir, 'opts.uploadDir');
assert.optionalNumber(opts.maxFieldsSize, 'opts.maxFieldsSize');
assert.optionalString(opts.hash, 'opts.hash');
assert.optionalFunc(opts.multipartFileHandler, 'opts.multipartFileHandler');
assert.optionalFunc(opts.multipartHandler, 'opts.multipartHandler');
assert.optionalBool(opts.mapParams, 'opts.mapParams');
assert.optionalBool(opts.mapFiles, 'opts.mapFiles');
assert.optionalNumber(opts.maxFileSize, 'opts.maxFileSize');
var override = opts.overrideParams;
function parseMultipartBody(req, res, originalNext) {
// save original body on req.rawBody and req._body
req.rawBody = req._body = undefined;
var next = once(originalNext);
if (
req.getContentType() !== 'multipart/form-data' ||
(req.getContentLength() === 0 && !req.isChunked())
function multipartBodyParser(options) {
var opts = options || {};
assert.object(opts, 'opts');
assert.optionalBool(opts.overrideParams, 'opts.overrideParams');
assert.optionalBool(opts.multiples, 'opts.multiples');
assert.optionalBool(opts.keepExtensions, 'opts.keepExtensions');
assert.optionalString(opts.uploadDir, 'opts.uploadDir');
assert.optionalNumber(opts.maxFieldsSize, 'opts.maxFieldsSize');
assert.optionalString(opts.hash, 'opts.hash');
assert.optionalFunc(opts.multipartFileHandler,
'opts.multipartFileHandler');
assert.optionalFunc(opts.multipartHandler, 'opts.multipartHandler');
assert.optionalBool(opts.mapParams, 'opts.mapParams');
assert.optionalBool(opts.mapFiles, 'opts.mapFiles');
var override = opts.overrideParams;
function parseMultipartBody(req, res, originalNext) {
// save original body on req.rawBody and req._body
req.rawBody = req._body = undefined;
var next = once(originalNext);
if (req.getContentType() !== 'multipart/form-data' ||
(req.getContentLength() === 0 && !req.isChunked())) {
return (next());
function Model(config) {
assert.object(config, 'config');
assert.string(config.name, 'config.name');
assert.optionalFunc(config.before, 'config.before');
assert.optionalFunc(config.after, 'config.after');
assert.optionalFunc(config.isValid, 'config.isValid');
// initialize instance level attributes
this.props = {};
this.data = {};
this.errors = [];
// merge down the config
this._mergeConfig(config);
// assign a logger if it wasn't passed in.
if (!this.log) {
this.log = LOG;
}
}
fhdb.prototype.close = function close(cb) {
assert.optionalFunc(cb, 'callback');
var log = this.log;
var self = this;
var _cb = once(function (err) {
if (err) {
log.error(err, 'close: failed');
if (cb) {
cb(err);
} else {
self.emit('error', err);
}
} else {
log.debug(err, 'close: done');
self.emit('close');
if (cb)
IMGADM.prototype.installImage = function installImage(options, callback) {
assert.object(options, 'options');
assert.object(options.manifest, 'options.manifest');
assert.string(options.zpool, 'options.zpool');
assert.string(options.file, 'options.file');
assert.optionalBool(options.quiet, 'options.quiet');
assert.optionalFunc(options.logCb, 'options.logCb');
this._installImage(options, callback);
};
function transformStream(args)
{
var stream;
mod_assertplus.object(args, 'args');
mod_assertplus.func(args.func, 'args.func');
mod_assertplus.optionalFunc(args.flush, 'args.flush');
mod_assertplus.optionalObject(args.streamOptions);
stream = new mod_stream.Transform(args.streamOptions);
stream._transform = args.func;
if (args.flush)
stream._flush = args.flush;
return (stream);
}
client.rollback = function rollback(cb) {
assert.optionalFunc(cb, 'callback');
cb = once(cb || function () {});
function _cb(err) {
client._moray_txn = false;
pool.release(client);
cb(err);
}
if (client._moray_txn) {
var q = client.query('ROLLBACK');
q.once('error', function (err) {
client._moray_had_err = true;
_cb(err);
});
q.once('end', function () {
_cb();