This commit is contained in:
David Arranz 2019-07-21 11:27:08 +02:00
parent 1d27ecb4a5
commit 0236c9b76e

View File

@ -5,6 +5,7 @@ const { extractParamsFromRequest, handleErrorResponse, handleResultResponse } =
function buildContext(req, config) {
return {
user: req.user,
scopes: [],
...config,
}
}
@ -50,6 +51,7 @@ const generateControllers = (service, extraControllers = {}, options = {}) => {
const result = await service.fetchOne(params, buildContext(req, config));
return handleResultResponse(result, null, params, res, (result === null) ? httpStatus.NOT_FOUND : httpStatus.OK);
} catch (error) {
console.log(error);
handleErrorResponse(_options.MODULE_NAME, 'findOne', error, res)
}
}