Skip to content

MalkovVladimir/feathers-global-params-from-client-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

feathers-global-params-from-client-hook

This is "soft" aletrnative of paramsFromClient hook. When you use paramsFromClient in app.hook.ts, it fully removes $client property (which contains all params), so we loose possibility to use params in service's hooks. globalParamsFromClient solve this problem.

paramsFromClient problem:

Client code:

await this.$store.dispatch('your-service/find',
  paramsForServer({
    query: { type: 'custom' },
    schema: 'alt-1'
  })
)

On server params will look like this:

{
  query: { type: 'custom' },
  $client: { schema: 'alt-1' }
}

app.hooks.ts:

export default {
  before: {
    ...
    find: [
      paramsFromClient('disableParanoid')
    ],
    ...
  }
}

It whitelist only "disableParanoid" param and remove all others ($client removed).

your-service.hooks.ts:

export default {
  before: {
    ...
    find: [
      paramsFromClient('schema')
    ],
    ...
  }
}

No effect, we will never get schema param, if use paramsFromClient in app.hook.ts.

globalParamsFromClient usage

app.hooks.ts:

export default {
  before: {
    ...
    find: [
      globalParamsFromClient('disableParanoid')
    ],
    ...
  }
}

It whitelist "disableParanoid" param, remove it from $client and pass all others to your paramsFromClient handlers.

your-service.hooks.ts:

export default {
  before: {
    ...
    find: [
      paramsFromClient('schema')
    ],
    ...
  }
}

So here you will get schema param!

About

Alternative of paramsFromClient hook for app.hook.ts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published