Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkContextIf(context1, 'before', ['update', 'patch'], 'hookName');
// $ExpectType Hook>
combine(hook1, hook2, hook3);
// $ExpectType Hook>
debug('label', 'abc.def', 'ghi.jkl');
// $ExpectType Hook>
dePopulate();
// $ExpectType Hook>
disablePagination();
// $ExpectType Hook>
disallow('external', 'server');
// $ExpectType Hook>
discard('abc', 'def');
// $ExpectType Hook>
discardQuery('abc', 'def');
softDelete({
removeData: async () => ({})
});
const commentResolvers: ResolverMap = {
joins: {
author: $select => async comment => {
const authors = await service1.find({
query: { id: comment.userId, $select: $select || ['name'] },
if (Healthcheck.error) {
res.status(500).json(_.pick(Healthcheck, ['jobId', 'error.code', 'error.message']))
} else {
res.status(200).json(_.omit(Healthcheck, ['error']))
}
})
// Setup default services used by CLI
TasksService.storesService = apiPrefix + '/stores'
JobsService.storesService = apiPrefix + '/stores'
JobsService.tasksService = apiPrefix + '/tasks'
app.use(apiPrefix + '/stores', StoresService)
app.use(apiPrefix + '/tasks', TasksService)
app.use(apiPrefix + '/jobs', JobsService)
// In API mode everything is open, otherwise only health check is
if (!options.api) {
app.service(apiPrefix + '/stores').hooks({ before: { all: [disallow('external')] } })
app.service(apiPrefix + '/tasks').hooks({ before: { all: [disallow('external')] } })
app.service(apiPrefix + '/jobs').hooks({ before: { all: [disallow('external')] } })
}
// Process hooks
_.forOwn(job.hooks, (value, key) => {
const service = app.service(apiPrefix + '/' + key)
hooks.activateHooks(value, service)
})
// Run the app, this is required to correctly setup Feathers
const port = options.port || 3030
if (options.api) console.log('Server listening to ' + port)
server = app.listen(port)
if (sync) {
server.on('close', () => app.sync.close())
}
await new Promise((resolve, reject) => {
} else {
res.status(200).json(_.omit(Healthcheck, ['error']))
}
})
// Setup default services used by CLI
TasksService.storesService = apiPrefix + '/stores'
JobsService.storesService = apiPrefix + '/stores'
JobsService.tasksService = apiPrefix + '/tasks'
app.use(apiPrefix + '/stores', StoresService)
app.use(apiPrefix + '/tasks', TasksService)
app.use(apiPrefix + '/jobs', JobsService)
// In API mode everything is open, otherwise only health check is
if (!options.api) {
app.service(apiPrefix + '/stores').hooks({ before: { all: [disallow('external')] } })
app.service(apiPrefix + '/tasks').hooks({ before: { all: [disallow('external')] } })
app.service(apiPrefix + '/jobs').hooks({ before: { all: [disallow('external')] } })
}
// Process hooks
_.forOwn(job.hooks, (value, key) => {
const service = app.service(apiPrefix + '/' + key)
hooks.activateHooks(value, service)
})
// Run the app, this is required to correctly setup Feathers
const port = options.port || 3030
if (options.api) console.log('Server listening to ' + port)
server = app.listen(port)
if (sync) {
server.on('close', () => app.sync.close())
}
await new Promise((resolve, reject) => {
server.on('listening', resolve)
server.on('error', reject)
const emotionRatingHook = require('./hooks/emotion-rating');
const { isVerified } = require('feathers-authentication-management').hooks;
const hooks = require('feathers-hooks-common');
module.exports = {
before: {
all: [authenticate('jwt')],
find: [],
get: [],
create: [
hooks.when(hooks.isProvider('external'),
isVerified()
)],
update: [hooks.disallow()],
patch: [hooks.disallow()],
remove: [hooks.disallow('external')]
},
after: {
all: [
// populate({ schema: userSchema }),
// populate({ schema: contributionSchema })
],
find: [],
get: [],
create: [emotionRatingHook()],
update: [],
patch: [],
remove: []
},
error: {
const contributionSchema = {
include: {
service: 'contributions',
nameAs: 'contribution',
parentField: 'relatedContributionId',
childField: '_id'
}
};
module.exports = {
before: {
all: [ ],
find: [ ...restrict ],
get: [ ...restrict ],
create: [ disallow('external') ],
update: [ ...restrict ],
patch: [ ...restrict ],
remove: [ ...restrict ]
},
after: {
all: [
populate({ schema: contributionSchema }),
populate({ schema: commentSchema })
],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
isEnabled(),
],
get: [
authenticate('jwt'),
isEnabled(),
],
create: [
hashPassword(),
verifyHooks.addVerification(),
setDefaultRole(),
setFirstUserToRole({role: 'admin'}),
preventDisabledAdmin(),
loopItems(setUserInitials)
],
update: [
commonHooks.disallow('external')
],
patch: [
...restrict,
commonHooks.iff(commonHooks.isProvider('external'), commonHooks.preventChanges(
'email',
'isVerified',
'verifyToken',
'verifyShortToken',
'verifyExpires',
'verifyChanges',
'resetToken',
'resetShortToken',
'resetExpires'
)),
preventDisabledAdmin(),
loopItems(setUserInitials)
const {
hashPassword, protect
} = require('@feathersjs/authentication-local').hooks;
module.exports = {
before: {
all: [],
find: [ authenticate('jwt') ],
get: [ authenticate('jwt') ],
create: [
hashPassword(),
verifyHooks.addVerification()
],
update: [
commonHooks.disallow('external')
],
patch: [
commonHooks.iff(
commonHooks.isProvider('external'),
commonHooks.preventChanges(true,
['email',
'isVerified',
'verifyToken',
'verifyShortToken',
'verifyExpires',
'verifyChanges',
'resetToken',
'resetShortToken',
'resetExpires']
),
hashPassword(),
const { disallow } = require('feathers-hooks-common');
module.exports = {
before: {
all: [
disallow('external')
],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
after: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],