diff options
author | eug-vs <eug-vs@keemail.me> | 2021-04-17 19:57:19 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-04-17 19:57:19 +0300 |
commit | 1da159d1102bf0ded9ce50d447c821258c7be800 (patch) | |
tree | fe6c86300f933abf0756b846d76bbe8f3abd63d6 /src/hooks | |
parent | f34d29c80850bdf582d1568dc98ae67d1895f082 (diff) | |
download | commercel-api-1da159d1102bf0ded9ce50d447c821258c7be800.tar.gz |
feat: add ignoreCaseRegex hook
Diffstat (limited to 'src/hooks')
-rw-r--r-- | src/hooks/ignoreCaseRegex.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hooks/ignoreCaseRegex.ts b/src/hooks/ignoreCaseRegex.ts new file mode 100644 index 0000000..e996000 --- /dev/null +++ b/src/hooks/ignoreCaseRegex.ts @@ -0,0 +1,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; |