How to use the feathers-hooks-common.discard function in feathers-hooks-common

To help you get started, we’ve selected a few feathers-hooks-common examples, based on popular ways it is used in public projects.

github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
combine(hook1, hook2, hook3);

// $ExpectType Hook<any, Service<any>>
debug('label', 'abc.def', 'ghi.jkl');

// $ExpectType Hook<any, Service<any>>
dePopulate();

// $ExpectType Hook<any, Service<any>>
disablePagination();

// $ExpectType Hook<any, Service<any>>
disallow('external', 'server');

// $ExpectType Hook<any, Service<any>>
discard('abc', 'def');

// $ExpectType Hook<any, Service<any>>
discardQuery('abc', 'def');

softDelete({
    removeData: async () => ({})
});

const commentResolvers: ResolverMap<any> = {
    joins: {
        author: $select => async comment => {
            const authors = await service1.find({
                query: { id: comment.userId, $select: $select || ['name'] },
                paginate: false
            });
            comment.author = authors[0];
github feathers-plus / feathers-redux / example-old / server / services / user / hooks / index.js View on Github external
find: auth.hooks.authenticate('jwt'),
  get: auth.hooks.authenticate('jwt'),
  create: local.hooks.hashPassword(),
  update: [
    auth.hooks.authenticate('jwt'),
    local.hooks.hashPassword()
  ],
  patch: [
    auth.hooks.authenticate('jwt'),
    local.hooks.hashPassword()
  ],
  remove: auth.hooks.authenticate('jwt'),
};

exports.after = {
  all: when(hook => hook.provider, discard('password')),
  create: emailVerification, // send email to verify the email addr  ],
};

function emailVerification(hook, next) {
  const user = hook.result;

  console.log('-- Sending email to verify new user\'s email addr');
  console.log(`Dear ${user.username}, please click this link to verify your email addr.`);
  console.log(`  http://localhost:3030/socket/verify/${user.verifyToken}`);

  next(null, hook);
}
github eddyystop / feathers-reduxify-services / example / server / services / user / hooks / index.js View on Github external
find: auth.hooks.authenticate('jwt'),
  get: auth.hooks.authenticate('jwt'),
  create: local.hooks.hashPassword(),
  update: [
    auth.hooks.authenticate('jwt'),
    local.hooks.hashPassword()
  ],
  patch: [
    auth.hooks.authenticate('jwt'),
    local.hooks.hashPassword()
  ],
  remove: auth.hooks.authenticate('jwt'),
};

exports.after = {
  all: when(hook => hook.provider, discard('password')),
  create: emailVerification, // send email to verify the email addr  ],
};

function emailVerification(hook, next) {
  const user = hook.result;

  console.log('-- Sending email to verify new user\'s email addr');
  console.log(`Dear ${user.username}, please click this link to verify your email addr.`);
  console.log(`  http://localhost:3030/socket/verify/${user.verifyToken}`);

  next(null, hook);
}
github Human-Connection / API / server / app.hooks.js View on Github external
// Application hooks that run for every service
// const logger = require('./hooks/logger');
const { discard } = require('feathers-hooks-common');

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [
      discard('_id', '__v')
    ],
    update: [
      discard('_id', '__v')
    ],
    patch: [
      discard('_id', '__v')
    ],
    remove: []
  },

  after: {
    all: [
      // logger()
    ],
    find: [],
    get: [],
github mariusandra / insights / packages / insights-core / app / services / users / users.hooks.js View on Github external
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: [],
    create: [],
    update: [],
github Human-Connection / API / server / services / contributions / contributions.hooks.js View on Github external
after: {
    all: [
      xss({fields: xssFields}),
      populate({schema: userSchema}),
      populate({schema: categoriesSchema}),
      populate({schema: candosSchema}),
      populate({schema: commentsSchema}),
      keepDeletedDataFields({
        fields: [
          '_id',
          'deleted',
          'createdAt',
          'updatedAt'
        ]
      }),
      discard('wasSeeded')
    ],
    find: [
      when(isSingleItem(),
        getAssociatedCanDos()
      ),
      populate({schema: organizationSchema}),
      thumbnails(thumbs)
    ],
    get: [
      getAssociatedCanDos(),
      populate({schema: organizationSchema}),
      thumbnails(thumbs)
    ],
    create: [
      createMentionNotifications(),
      notifyFollowers(),
github codingfriend1 / Feathers-Vue / server / services / users / users.hooks.js View on Github external
'resetShortToken',
        'resetExpires'
      )),
      preventDisabledAdmin(),
      loopItems(setUserInitials)
    ],
    remove: [ 
      ...restrict
    ]
  },

  after: {
    all: [
      commonHooks.when(
        hook => hook.params.provider,
        commonHooks.discard('password', '_computed', 'verifyExpires', 'resetExpires', 'verifyChanges')
      ),
    ],
    find: [
      commonHooks.populate({ schema }),
      commonHooks.serialize(serializeSchema),
    ],
    get: [
      commonHooks.populate({ schema }),
      commonHooks.serialize(serializeSchema),
    ],
    create: [
      sendVerificationEmail(),
      verifyHooks.removeVerification()
    ],
    update: [
      commonHooks.populate({ schema }),
github kalisio / feathers-distributed / example / gateway / src / services / users / users.hooks.js View on Github external
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: [],
    create: [],
    update: [],
github Human-Connection / API / server / services / comments / comments.hooks.js View on Github external
remove: [
      authenticate('jwt'),
      unless(isProvider('server'),
        unless(isModerator(),
          isVerified(),
          restrictToOwner()
        )
      )
    ]
  },

  after: {
    all: [
      xss({ fields: xssFields }),
      keepDeletedDataFields(),
      discard('wasSeeded')
    ],
    find: [
      populate({ schema: userSchema }),
      protect('content', 'badgeIds'),
      concealBlacklistedData({
        data: {
          content: 'Comments of this blacklisted user are not visible.',
          contentExcerpt: 'Comments of this blacklisted user are not visible.',
          hasMore: false
        }
      })
    ],
    get: [
      populate({ schema: userSchema }),
      concealBlacklistedData({
        data: {