Skip to content

Commit

Permalink
refactor(internals): ensure returned values
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Aug 5, 2021
1 parent 2b0313a commit c977213
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"async": ">=3.2.0",
"auto-parse": ">=1.8.0",
"express": ">=4.17.1",
"lodash": ">=4.17.20"
"lodash": ">=4.17.21"
},
"config": {
"commitizen": {
Expand Down
32 changes: 16 additions & 16 deletions src/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export const filter = (options, done) => {

// TODO ignore ['$jsonSchema', '$where']

done(null, filters);
return done(null, filters);
} catch (error) {
// catch all errors
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

Expand Down Expand Up @@ -132,12 +132,12 @@ export const headers = (options, done) => {
includes(DATE_HEADERS, key) ? new Date(value) : value
);

done(null, payload);
return done(null, payload);
} catch (error) {
// catch all errors
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

Expand Down Expand Up @@ -215,12 +215,12 @@ export const paginate = (options, done) => {
skip = !hasSkip && page > 0 ? (page - 1) * limit : skip;
paginations = merge({}, paginations, { skip });

done(null, paginations);
return done(null, paginations);
} catch (error) {
// catch all errors
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

Expand Down Expand Up @@ -341,12 +341,12 @@ export const select = (options, done) => {
{}
);

done(null, projections);
return done(null, projections);
} catch (error) {
// catch all errors
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

Expand Down Expand Up @@ -431,7 +431,7 @@ export const populate = (options, done) => {
populations = compact([].concat(populations));

// build populations
waterfall(
return waterfall(
[
// parse field selections
(next) => {
Expand Down Expand Up @@ -470,7 +470,7 @@ export const populate = (options, done) => {
// catch all errors
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

Expand Down Expand Up @@ -536,21 +536,21 @@ export const sort = (options, done) => {
);
}

done(null, sorts);
return done(null, sorts);
} catch (error) {
// catch all errors
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

/**
* @name parse
* @param done
* @function parse
* @param {string} string valid json string
* @description parse specified JSON string into Javascript value or object
* @param {string} string valid json string
* @param {Function} done a callback to invoke on success or failure
* @returns {object} constructed JavaScript value or object from JSON key value
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse}
* @author lally elias <lallyelias87@mail.com>
Expand All @@ -565,7 +565,7 @@ export const parse = (string, done) => {
try {
const json = autoParse(string);

parallel(
return parallel(
{
filter: (next) => filter(json, next),
headers: (next) => headers(json, next),
Expand Down Expand Up @@ -598,7 +598,7 @@ export const parse = (string, done) => {
} catch (error) {
error.message = error.message || 'Bad Request';
error.status = 400;
done(error);
return done(error);
}
};

Expand Down

0 comments on commit c977213

Please sign in to comment.