How to use feathers-hooks-common - 10 common examples

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathers-plus / generator-feathers-plus / test-expands / cumulative-2-sequelize-services.test-expected / src1 / services / nedb-1 / nedb-1.validate.js View on Github external
let validateUpdate = options => {
  // !<DEFAULT> code: func_update
  return validateSchema(update, ajv, options);
  // !end
};
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
}
});
// $ExpectType Hook<any, Service<any>>
traverse(function(node) {
    if (typeof node === 'string') {
        this.update(node.trim());
    }
}, context => context.params.query);

// $ExpectType Hook<any, Service<any>>
validate(async (data, context) => {
    return { length: 'expected max 3, got 7' };
});

// $ExpectType Hook<any, Service<any>>
validateSchema({}, ajv);

// $ExpectType Hook<any, Service<any>>
iffElse(syncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType Hook<any, Service<any>>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);

// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook<any, Service<any>>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType IffHook
github feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-mongoose.test-expected / src1 / services / nedb-2 / nedb-2.validate.ts View on Github external
let validatePatch = (options?: any) => {
  // !<DEFAULT> code: func_patch
  return validateSchema(patch, ajv, options);
  // !end
};
github feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-mongoose.test-expected / src1 / services / nedb-2 / nedb-2.validate.ts View on Github external
let validateUpdate = (options?: any) => {
  // !<DEFAULT> code: func_update
  return validateSchema(update, ajv, options);
  // !end
};
github feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-mongo.test-expected / src1 / services / nedb-1 / nedb-1.validate.ts View on Github external
let validateUpdate = (options?: any) => {
  // !<DEFAULT> code: func_update
  return validateSchema(update, ajv, options);
  // !end
};
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
// $ExpectType Hook<any, Service<any>>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);

// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook<any, Service<any>>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
when(syncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType Hook<any, Service<any>>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
unless(syncTrue, hook1, hook2);

// $ExpectType AsyncContextFunction<boolean>
some(asyncFalse, asyncTrue, syncTrue);

// $ExpectType AsyncContextFunction<boolean>
every(asyncTrue, syncTrue);

// $ExpectType AsyncContextFunction<boolean>
isNot(asyncTrue);
// $ExpectType AsyncContextFunction<boolean>
isNot(syncTrue);
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
// $ExpectType Hook<any, Service<any>>
iffElse(syncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType Hook<any, Service<any>>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);

// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook<any, Service<any>>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
when(syncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType Hook<any, Service<any>>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
unless(syncTrue, hook1, hook2);

// $ExpectType AsyncContextFunction<boolean>
some(asyncFalse, asyncTrue, syncTrue);

// $ExpectType AsyncContextFunction<boolean>
every(asyncTrue, syncTrue);

// $ExpectType AsyncContextFunction<boolean>
isNot(asyncTrue);
github feathers-plus / generator-feathers-plus / test-expands / a-gens / js / test-hook-integ.test-expected / src1 / hooks / hook.app1.js View on Github external
return async (context) => {
    // Throw if the hook is being called from an unexpected location.
    checkContext(context, null, ['find', 'get', 'create', 'update', 'patch', 'remove']);

    // Get the authenticated user.
    // eslint-disable-next-line no-unused-vars
    const { user } = context.params;
    // Get the record(s) from context.data (before), context.result.data or context.result (after).
    // getItems always returns an array to simplify your processing.
    const records = getItems(context);

    /*
    Modify records and/or context.
     */

    // Place the modified records back in the context.
    replaceItems(context, records);
    // Best practice: hooks should always return the context.
    return context;
  };
};
github feathers-plus / generator-feathers-plus / examples / js / 12-test-examples / feathers-app / src / services / users / hooks / verify-email.js View on Github external
return async (context) => {
    // Throw if the hook is being called from an unexpected location.
    checkContext(context, 'after', ['find', 'get', 'create', 'update', 'patch', 'remove']);

    // Get the authenticated user.
    // eslint-disable-next-line no-unused-vars
    const { user } = context.params;
    // Get the record(s) from context.data (before), context.result.data or context.result (after).
    // getItems always returns an array to simplify your processing.
    const records = getItems(context);

    /*
    Modify records and/or context.
     */

    // Place the modified records back in the context.
    replaceItems(context, records);
    // Best practice: hooks should always return the context.
    return context;
  };
};
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
// $ExpectType Hook<any, Service<any>>
validateSchema({}, ajv);

// $ExpectType Hook<any, Service<any>>
iffElse(syncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType Hook<any, Service<any>>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);

// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook<any, Service<any>>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
when(syncTrue, hook1, hook2).else(hook3, hook4);

// $ExpectType Hook<any, Service<any>>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook<any, Service<any>>
unless(syncTrue, hook1, hook2);

// $ExpectType AsyncContextFunction<boolean>
some(asyncFalse, asyncTrue, syncTrue);

// $ExpectType AsyncContextFunction<boolean>
every(asyncTrue, syncTrue);