Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// $ExpectType Hook>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook>
when(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook>
unless(syncTrue, hook1, hook2);
// $ExpectType AsyncContextFunction
some(asyncFalse, asyncTrue, syncTrue);
// $ExpectType AsyncContextFunction
every(asyncTrue, syncTrue);
// $ExpectType AsyncContextFunction
isNot(asyncTrue);
// $ExpectType AsyncContextFunction
isNot(syncTrue);
// $ExpectType Hook>
iffElse(syncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType Hook>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook>
when(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook>
unless(syncTrue, hook1, hook2);
// $ExpectType AsyncContextFunction
some(asyncFalse, asyncTrue, syncTrue);
// $ExpectType AsyncContextFunction
every(asyncTrue, syncTrue);
// $ExpectType AsyncContextFunction
isNot(asyncTrue);
hook.data.isVerified = true;
return hook;
}
),
when(isProvider('external'),
restrictUserRole(),
createAdmin()
),
saveRemoteImages(['avatar', 'coverImg'])
],
update: [
...restrict,
hashPassword(),
disableMultiItemChange(),
lowerCase('email', 'username'),
when(isProvider('external'),
restrictUserRole()
),
saveRemoteImages(['avatar', 'coverImg'])
],
patch: [
...restrict,
disableMultiItemChange(),
lowerCase('email', 'username'),
// Only set slug once
when(
hook => {
return hook.params && hook.params.user && !hook.params.user.slug;
},
createSlug({ field: 'name' })
),
when(isProvider('external'),
module.exports = {
before: {
all: [],
find: [
// authenticate('jwt'),
search(),
search({
fields: ['name', 'email']
})
],
get: [],
create: [
hashPassword(),
lowerCase('email', 'username'),
when(isProvider('external'),
inviteCode.before
),
// We don't need email verification
// for server generated users
addVerification(),
when(isProvider('server'),
hook => {
hook.data.isVerified = true;
return hook;
}
),
when(isProvider('external'),
restrictUserRole(),
createAdmin()
),
saveRemoteImages(['avatar', 'coverImg'])
module.exports = {
before: {
all: [
softDelete(),
xss({fields: xssFields})
],
find: [
iff(
hook => hook.params.headers && hook.params.headers.authorization,
authenticate('jwt')
),
unless(isModerator(),
excludeDisabled()
),
excludeBlacklisted(),
when(isProvider('server'),
includeAll()
),
search(),
search({
fields: ['title', 'content']
})
],
get: [
unless(isModerator(),
excludeDisabled()
)
],
create: [
authenticate('jwt'),
// Allow seeder to seed contributions
associateCurrentUser(),
restrictToOwnerOrModerator({ isEnabled: true, reviewedBy: { $ne: null } }),
search(),
search({
fields: ['name', 'email']
})
],
get: [
restrictToOwnerOrModerator({ isEnabled: true, reviewedBy: { $ne: null } })
],
create: [
authenticate('jwt'),
// Allow seeder to seed contributions
unless(isProvider('server'),
isVerified()
),
when(isModerator(),
hook => {
hook.data.reviewedBy = hook.params.user.userId;
return hook;
}
),
associateCurrentUser(),
createSlug({ field: 'name' }),
createExcerpt({ field: 'description' }),
saveRemoteImages(['logo', 'coverImg'])
],
update: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified()
),
stashBefore(),
update: [
...restrict,
hashPassword(),
disableMultiItemChange(),
lowerCase('email', 'username'),
when(isProvider('external'),
restrictUserRole()
),
saveRemoteImages(['avatar', 'coverImg'])
],
patch: [
...restrict,
disableMultiItemChange(),
lowerCase('email', 'username'),
// Only set slug once
when(
hook => {
return hook.params && hook.params.user && !hook.params.user.slug;
},
createSlug({ field: 'name' })
),
when(isProvider('external'),
restrictUserRole()
),
saveRemoteImages(['avatar', 'coverImg'])
],
remove: [
...restrict,
disableMultiItemChange(),
removeAllRelatedUserData()
]
},
];
module.exports = {
before: {
all: [],
find: [ authenticate('jwt') ],
get: [ ...restrict ],
create: [ hashPassword() ],
update: [ ...restrict, hashPassword() ],
patch: [ ...restrict, hashPassword() ],
remove: [ ...restrict ]
},
after: {
all: [
commonHooks.when(
hook => hook.params.provider,
commonHooks.discard('password')
)
],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],
]
module.exports = {
before: {
all: [],
find: [],
get: [ ...restrict ],
create: [ hashPassword() ],
update: [ ...restrict, hashPassword() ],
patch: [ ...restrict, hashPassword() ],
remove: [ ...restrict ]
},
after: {
all: [
commonHooks.when(
hook => hook.params.provider,
commonHooks.discard('password')
)
],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],