Gathering detailed insights and metrics for fixate-feathers-hooks
Gathering detailed insights and metrics for fixate-feathers-hooks
Gathering detailed insights and metrics for fixate-feathers-hooks
Gathering detailed insights and metrics for fixate-feathers-hooks
npm install fixate-feathers-hooks
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
32 Commits
1 Forks
2 Watchers
1 Branches
1 Contributors
Updated on May 15, 2019
Latest Version
2.1.8
Package Id
fixate-feathers-hooks@2.1.8
Unpacked Size
14.60 kB
Size
5.09 kB
File Count
14
NPM Version
6.4.1
Node Version
8.9.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
3
1
A mixed bag of feathers hooks that are useful in almost all projects.
They all curry the hook function, so the 'outer' call is used for configuration and returns a function.
Dependencies:
optionalHashPassword
below)Install: npm install --save fixate-feathers-hooks
Include:
const defaults = require('fixate-feathers-hooks/defaults')
or
const { defaults } = require('fixate-feathers-hooks');
Specify default query params or results. You can also use a function which returns a calculated default.
1defaults({ q: 'foo', complex(hook) { return hook.params.anotherField } }, { deep: true })(hook); 2// (before hook) params = { q: 'bar', anotherField: 'test123' } then params.query will have { q:'bar', complex: 'test123' }
Workaround for issue. Copy of feathers-authentication's hashPassword
hook, but we can use this in
updates and patches because it doesn't try and hash a falsey password.
TODO: remove; fixed in PR#287
Select fields in data
(before hook) or result
(after hook) to allow through using dot notation
(lodash get). Handles deeply nested objects too.
1permitFields('public.object', 'private.item.name')(hook);
Configure fields which should be removed from api responses.
Configure sensitiveFields
in your default.json
(uses app.get
and feathers-hooks.remove
hook).
>= 1.0.4
- Will throw an error if you use this hook without a configuration for the "model". This is to prevent typos causing data to leak.
1removeSensitiveFields('user')(hook); 2 3// default.json 4... 5"sensitiveFields": { 6 "user": ["password", "forgottenPasswordToken", ...], 7 "creditCard": ["cvv"], 8}
Specify and validate required params - if params are missing throw an error (BadRequest by default
)
1requiredParams('firstName', 'lastName', 'email', { Error: new Error('My custom error') })(hook);
Will ensure that hook.params.query
has the specified values.
1scopeQueryTo({ status: 'active' })(hook); 2 3// with function 4const scopeToOwner = scopeQueryTo(hook => ({ user: hook.user._id })); 5exports.before = { 6 find: scopeToOwner, 7 get: scopeToOwner, 8 update: scopeToOwner, 9 patch: scopeToOwner, 10 remove: scopeToOwner, 11};
Sets the data
object to a field contained in hooks.user
object.
If overwrite
is false
, then only set if data value is empty
(probably want to be careful of doing that).
1// with default options (except field which is required) 2setUserField({ field: 'user', userField: '_id', overwrite: true })(hook);
Slugifies fields in object and sets the result to another field.
1slugify('mySlug', 'firstName'/*, overwrite = false*/); 2// Or 3slugify('mySlug', ['firstName', 'lastName']/*, overwrite = false*/);
Sets the current timestamp
1// true = Overwrites 2const updatedAt = timestamp('updatedAt', true); 3// Does not overwrite - note: if your database defaults to now you won't need this :) 4const createdAt = timestamp('createdAt'); 5export.before = { 6 create: createdAt, 7 update: updatedAt, 8 patch: updatedAt, 9}
Calls your options.userService
service to check if options.field
already exists. If not, it
will BadRequest
, otherwise it'll let the request continue. Asynchronous, returns promise.
Useful for protecting against mongoose duplicate key errors and returning a useful error.
1// with defaults 2validateUnique({ field: 'username', userService: '/users' })(hook);
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
17 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More