Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getEmails = async (pageNo = 1) => {
const response = await fetch(`${baseUrl}/api/inbox?page=${pageNo}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
if (response.status === 200) {
const body = await response.json();
// console.log('response: ', body);
const res = camelizeKeys(body)
console.log('RES: ', res);
return camelizeKeys(body);
}
throw new Error('Can not fetch emails');
};
try {
response = yield call(sagaFetch, endpointPath, options)
} catch (error) {
updateRunningFetches(error.response)
yield fork(handleRequestError, error, action)
return false
}
const { json, serverResponse } = response
updateRunningFetches(serverResponse)
payload.serverStatus = serverResponse.status
if (serverResponse.status === 200 || serverResponse.status === 201) {
payload.response = camelizeKeys(json)
const linkPagination = parseLink(serverResponse.headers.get('Link'))
// for now these need to remain parseInt instead of Number cast
// due to StreamContainer casting them as number and checking for 0
// when you do Number(null) it equals 0, thanks javascript!
linkPagination.totalCount = parseInt(serverResponse.headers.get('X-TotalCount'), 10)
linkPagination.totalPages = parseInt(serverResponse.headers.get('X-Total-Pages'), 10)
linkPagination.totalPagesRemaining = parseInt(serverResponse.headers.get('X-Total-Pages-Remaining'), 10)
payload.pagination = linkPagination
}
yield put({ meta, payload, type: SUCCESS })
yield call(fireSuccessAction)
return true
}
// If it is an absolute url.
const url = getUrl(endpoint);
const options = { url, method };
if (jwt) {
options.headers = {
Authorization: `Bearer ${jwt}`,
};
}
if (body) {
if (method === 'GET' && body != null) {
// Convert body to ?x=y&b=a format
options.url += optionsToParameterizedUrl(decamelizeKeys(body));
} else {
options.data = decamelizeKeys(body);
}
}
const result = await axios(options);
const camelizedData = shouldCamelize
? camelizeKeys(result.data)
: result.data;
// Quickfix to prevent underscored dependencies from being camelized.
// Never store data as keys in the future.
if (
camelizedData &&
camelizedData.data &&
const url = getUrl(endpoint);
const options = { url, method };
if (jwt) {
options.headers = {
Authorization: `Bearer ${jwt}`,
};
}
if (body) {
if (method === 'GET' && body != null) {
// Convert body to ?x=y&b=a format
options.url += optionsToParameterizedUrl(decamelizeKeys(body));
} else {
options.data = decamelizeKeys(body);
}
}
const result = await axios(options);
return shouldCamelize ? camelizeKeys(result.data) : result.data;
});
.leftJoin('user_profile AS up', 'up.user_id', 'u.id')
.leftJoin('auth_certificate AS ca', 'ca.user_id', 'u.id')
.leftJoin('auth_facebook AS fa', 'fa.user_id', 'u.id')
.leftJoin('auth_google AS ga', 'ga.user_id', 'u.id')
.leftJoin('auth_github AS gha', 'gha.user_id', 'u.id')
.leftJoin('auth_linkedin AS lna', 'lna.user_id', 'u.id');
// add order by
if (orderBy && orderBy.column) {
let column = orderBy.column;
let order = 'asc';
if (orderBy.order) {
order = orderBy.order;
}
queryBuilder.orderBy(decamelize(column), order);
}
// add filter conditions
if (filter) {
if (has(filter, 'role') && filter.role !== '') {
queryBuilder.where(function() {
this.where('u.role', filter.role);
});
}
if (has(filter, 'isActive') && filter.isActive !== null) {
queryBuilder.where(function() {
this.where('u.is_active', filter.isActive);
});
}
public selectBy = (schema: typeof Schema, fields: string[]) => {
const domainSchema = new DomainSchema(schema);
// form table name
const tableName = decamelize(domainSchema.__.name);
// select fields
const parentPath = [];
const selectItems = [];
const joinNames = [];
this._getSelectFields(fields, parentPath, domainSchema, selectItems, joinNames, []);
debug('Select items:', selectItems);
debug('Join on tables:', joinNames);
return query => {
// join table names
joinNames.map(joinName => {
query.leftJoin(joinName, `${joinName}.${tableName}_id`, `${tableName}.id`);
});
include
);
// Set success callback
fetchAction.payload.dispatch[1] = (
jsonData => dispatch => {
dispatch(fetchItemSuccess(jsonData));
}
);
// Dispatch action
dispatch(fetchAction);
};
};
// Remap the above methods to methods including item name
var returned = {};
const camelizedAction = humps.pascalize(action);
returned["loadPaginated" + camelizedAction] = loadPaginatedItems;
returned["load" + camelizedAction.rstrip("s")] = loadItem;
return returned;
}
humps.camelizeKeys(someObject, function (key, convert) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});
humps.decamelizeKeys(someObject, function (key, convert, options) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});
humps.camelize('hello_world-foo bar');
humps.pascalize('hello_world-foo bar');
humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })
humps.depascalize('helloWorldFooBar');
humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);
humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);
humps.camelizeKeys(someObject, someOptions2);
humps.pascalizeKeys(someObject, someOptions2);
humps.camelizeKeys(someObject, function (key, convert) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});
humps.decamelizeKeys(someObject, function (key, convert, options) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});
humps.camelize('hello_world-foo bar');
humps.pascalize('hello_world-foo bar');
humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })
humps.depascalize('helloWorldFooBar');
humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);
humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);
humps.camelizeKeys(someObject, someOptions2);
humps.pascalizeKeys(someObject, someOptions2);
humps.decamelizeKeys(someObject, someOptions2);
humps.camelizeKeys(someObject);
humps.camelizeKeys(someArray);
humps.camelizeKeys(someObject, function (key, convert) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});
humps.decamelizeKeys(someObject, function (key, convert, options) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});
humps.camelize('hello_world-foo bar');
humps.pascalize('hello_world-foo bar');
humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })
humps.depascalize('helloWorldFooBar');
humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);
humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);