Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function (req, res, next) {
var request;
var error;
var serviceMeta;
if (req.method === GET) {
var path = req.path.substr(1).split(';');
var resource = path.shift();
if (!Fetcher.isRegistered(resource)) {
error = fumble.http.badRequest('Invalid Fetchr Access', {
debug: 'Bad resource ' + sanitizeResourceName(resource)
});
error.source = 'fetchr';
return next(error);
}
serviceMeta = [];
request = new Request(OP_READ, resource, {
req: req,
serviceMeta: serviceMeta,
statsCollector: options.statsCollector,
paramsProcessor: options.paramsProcessor
});
request
.params(parseParamValues(qs.parse(path.join('&'))))
.end(function (err, data) {
var meta = serviceMeta[0] || {};
export default function gatewayTimeoutError(context, payload, done) {
log.error(context, 'Gateway timeout');
const error = fumble.http.badRequest();
ErrorsList.GATEWAY_TIMEOUT_ERROR.statusCode = error.statusCode;
ErrorsList.GATEWAY_TIMEOUT_ERROR.statusText = error.message;
context.dispatch('GATEWAY_TIMEOUT_ERROR', ErrorsList.GATEWAY_TIMEOUT_ERROR);
done(error);
}
export default function deckContentTypeError(context, payload, done) {
log.error(context, {deck_id: payload.params.id, stype:payload.params.stype, text: 'Invalid deck content type'});
const error = fumble.http.badRequest();
ErrorsList.DECK_CONTENT_TYPE_ERROR.statusCode = error.statusCode;
ErrorsList.DECK_CONTENT_TYPE_ERROR.statusText = error.message;
context.dispatch('DECK_CONTENT_TYPE_ERROR', ErrorsList.DECK_CONTENT_TYPE_ERROR);
done(error);
}
export default function deckContentPathError(context, payload, done) {
log.error(context, {deck_id: payload.params.id, spath: payload.params.spath, text: 'Invalid deck content path'});
const error = fumble.http.badRequest();
ErrorsList.DECK_CONTENT_TYPE_ERROR.statusCode = error.statusCode;
ErrorsList.DECK_CONTENT_TYPE_ERROR.statusText = error.message;
context.dispatch('DECK_CONTENT_TYPE_ERROR', ErrorsList.DECK_CONTENT_TYPE_ERROR);
done(error);
}
export default function tooManyRequestsError(context, payload, done) {
log.error(context, 'Too many requests');
const error = fumble.http.tooManyRequests();
ErrorsList.TOO_MANY_REQUESTS_ERROR.statusCode = error.statusCode;
ErrorsList.TOO_MANY_REQUESTS_ERROR.statusText = error.message;
context.dispatch('TOO_MANY_REQUESTS_ERROR', ErrorsList.TOO_MANY_REQUESTS_ERROR);
done(error);
}
export default function searchSyntaxError(context, payload, done) {
log.error(context, 'Search syntax error');
const error = fumble.http.badRequest();
ErrorsList.SEARCH_SYNTAX_ERROR.statusCode = error.statusCode;
ErrorsList.SEARCH_SYNTAX_ERROR.statusText = error.message;
context.dispatch('SEARCH_SYNTAX_ERROR', ErrorsList.SEARCH_SYNTAX_ERROR);
done(error);
}
export default function methodNotAllowedError(context, payload, done) {
log.error(context, 'Method not allowed');
const error = fumble.http.methodNotAllowed();
ErrorsList.METHOD_NOT_ALLOWED_ERROR.statusCode = error.statusCode;
ErrorsList.METHOD_NOT_ALLOWED_ERROR.statusText = error.message;
context.dispatch('METHOD_NOT_ALLOWED_ERROR', ErrorsList.METHOD_NOT_ALLOWED_ERROR);
done(error);
}
export default function deckIdTypeError(context, payload, done) {
log.error(context, {deck_id: payload.params.id, text: 'Invalid deck id'});
const error = fumble.http.badRequest();
ErrorsList.DECK_ID_TYPE_ERROR.statusCode = error.statusCode;
ErrorsList.DECK_ID_TYPE_ERROR.statusText = error.message;
context.dispatch('TOO_MANY_REQUESTS_ERROR', ErrorsList.DECK_ID_TYPE_ERROR);
done(error);
}
error => {
if (error.response) {
return rejectWith(fumble.http.create(error.response.status), {
name,
formattedUrl,
reason: error.response.data
});
}
return rejectWith(fumble.http.create(500), {
name,
formattedUrl,
reason: error.message
});
}
);
export default function slideIdTypeError(context, payload, done) {
log.error(context, 'Invalid slide id');
const error = fumble.http.badRequest();
ErrorsList.SLIDE_ID_TYPE_ERROR.statusCode = error.statusCode;
ErrorsList.SLIDE_ID_TYPE_ERROR.statusText = error.message;
context.dispatch('SLIDE_ID_TYPE_ERROR', ErrorsList.SLIDE_ID_TYPE_ERROR);
done(error);
}