How to use the @feathersjs/commons._.isObject function in @feathersjs/commons

To help you get started, we’ve selected a few @feathersjs/commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathersjs / feathers / packages / adapter-commons / src / filter-query.ts View on Github external
function cleanQuery (query: any, operators: any, filters: any): any {
  if (Array.isArray(query)) {
    return query.map(value => cleanQuery(value, operators, filters));
  } else if (_.isObject(query) && query.constructor === {}.constructor) {
    const result: { [key: string]: any } = {};

    _.each(query, (value, key) => {
      if (key[0] === '$') {
        if (filters[key] !== undefined) {
          return;
        }

        if (!operators.includes(key)) {
          throw new BadRequest(`Invalid query parameter ${key}`, query);
        }
      }

      result[key] = cleanQuery(value, operators, filters);
    });