Skip to content

Commit

Permalink
refactor(transformService): add default object for transforms param
Browse files Browse the repository at this point in the history
  • Loading branch information
ComfortablyCoding committed Feb 16, 2023
1 parent 87a618a commit f2ee70b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/services/transform-service/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _ = require('lodash');
* @param {boolean} transforms.wrapBodyWithDataKey
* @param {object} ctx
*/
function transformRequest(transforms, ctx) {
function transformRequest(transforms = {}, ctx) {
// wrapBodyWithDataKey
if (transforms.wrapBodyWithDataKey) {
wrapBodyWithDataKey(ctx);
Expand Down
4 changes: 2 additions & 2 deletions server/services/transform-service/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { removeObjectKey } = require('./util');
* @param {boolean} transforms.removeDataKey
* @param {object} ctx
*/
function transformResponse(transforms, ctx) {
function transformResponse(transforms = {}, ctx) {
// transform data
if (transforms.removeAttributesKey || transforms.removeDataKey) {
ctx.body.data = modifyResponseBodyData(transforms, ctx.body.data);
Expand All @@ -24,7 +24,7 @@ function transformResponse(transforms, ctx) {
* @param {object} data
* @returns {object} transformed body data
*/
function modifyResponseBodyData(transforms, data) {
function modifyResponseBodyData(transforms = {}, data) {
// removeAttributeKey specific transformations
if (transforms.removeAttributesKey) {
// single
Expand Down

0 comments on commit f2ee70b

Please sign in to comment.