Remove step from catalog middleware

This commit is contained in:
Daniel García Aubert 2017-11-17 18:32:19 +01:00
parent 804c6645fa
commit c1f2b96bfc

View File

@ -28,26 +28,21 @@ AnalysesController.prototype.register = function(app) {
AnalysesController.prototype.catalog = function () {
return function catalogMiddleware(req, res, next) {
const { user } = res.locals;
const pg = new PSQL(dbParamsFromReqParams(res.locals));
step(
function catalogQuery() {
var pg = new PSQL(dbParamsFromReqParams(res.locals));
getMetadata(user, pg, this);
},
function prepareResponse(err, catalogWithTables) {
if (err) {
if (err.message.match(/permission\sdenied/)) {
err = new Error('Unauthorized');
err.http_status = 401;
}
return next(err);
getMetadata(user, pg, (err, catalogWithTables) => {
if (err) {
if (err.message.match(/permission\sdenied/)) {
err = new Error('Unauthorized');
err.http_status = 401;
}
res.locals.catalogWithTables = catalogWithTables;
next();
return next(err);
}
);
res.locals.catalogWithTables = catalogWithTables;
next();
});
};
};