summaryrefslogtreecommitdiff
path: root/src/hooks/ignoreCaseRegex.ts
blob: e996000eb4fc1d67140381f91b6944a8d3163104 (plain)
1
2
3
4
5
6
7
8
9
10
11
import { HookContext } from '@feathersjs/feathers';
import _ from 'lodash';

const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => {
  context.params.query = _.mapValues(context.params.query, (data, key) => {
    return key.startsWith('$') ? data : _.set(data, '$options', 'i');
  });
  return context;
};

export default ignoreCaseRegex;