Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
form.parse(request, (error, { operations }, files) => {
if (error) reject(new Error(error))
// Decode the GraphQL operation(s). This is an array if batching is
// enabled.
operations = JSON.parse(operations)
// Check if files were uploaded
if (Object.keys(files).length) {
// File field names contain the original path to the File object in the
// GraphQL operation input variables. Relevent data for each uploaded
// file now gets placed back in the variables.
const operationsPath = objectPath(operations)
Object.keys(files).forEach(variablesPath => {
const { name, type, size, path } = files[variablesPath]
operationsPath.set(variablesPath, { name, type, size, path })
})
}
// Provide fields for replacement request body
resolve(operations)
})
})
form.parse(request, (error, { operations }, files) => {
if (error) {
reject(new Error(error));
}
// Decode the GraphQL operation(s). This is an array
// if batching is enabled.
operations = JSON.parse(operations);
// Check if files were uploaded
if (Object.keys(files).length) {
// File field names contain the original path to
// the File object in the GraphQL operation input
// variables. Relevent data for each uploaded file
// now gets placed back in the variables.
const operationsPath = objectPath(operations);
Object.keys(files).forEach(variablesPath => {
const { name, type, size, path } = files[variablesPath];
operationsPath.set(variablesPath, { name, type, size, path });
});
}
// Provide fields for replacement request body
resolve(operations);
});
});
form.parse(req, (error, { operations }, files) => {
if (error) {
return reject(new Error(error));
}
debug('parsing form data');
// Decode the GraphQL operation(s). This is an array
// if batching is enabled.
operations = JSON.parse(operations);
// Check if files were uploaded
if (Object.keys(files).length) {
// File field names contain the original path to
// the File object in the GraphQL operation input
// variables. Relevent data for each uploaded file
// now gets placed back in the variables.
const operationsPath = objectPath(operations);
Object.keys(files).forEach(variablesPath => {
const { name, type, size, path } = files[variablesPath];
return operationsPath.set(variablesPath, { name, type, size, path });
});
}
// Provide fields for replacement request body
return resolve(operations);
});
});
updateState = (newState, callback) => {
let state = this.state;
let stateModel = ObjectPath(state);
for (let property in newState) {
if (newState.hasOwnProperty(property)) {
stateModel.set(property, newState[property]);
}
}
if (callback) {
this.setState(state, callback);
} else {
this.setState(state);
}
};
};
componentDidMount() {
const sources = ObjectPath(this.props).get('options.sources') || []
const isSource = sources.length
if (!this.player && isSource) {
this.initialize();
}
}
withProps(({ state, texts, data }) => ({
data: objectPath(data),
confirmSearch: () => {
const categories = []
Object.keys(state).forEach((key) => {
if (state[key]) {
categories.push(key)
}
})
const queryParam = {
searchTexts: texts,
categories: categories.join(',')
}
if (categories.length < 1) {
queryParam.categories = Object.keys(Categories).join(',')
}
Router.push(`/results?${queryString.stringify(queryParam)}`)
resetUrl() {
const sources = ObjectPath(this.props).get('options.sources') || []
sources[0] && this.player.src(sources[0].src);
this.player.poster(this.props.options.poster);
}
.scan((state, [ scope, reducer ]) =>
immutable.set(state, scope, reducer(objectPath(state, scope)))
)