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 => {
  // ! code: func_update
  return validateSchema(update, ajv, options);
  // !end
};
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
}
});
// $ExpectType Hook>
traverse(function(node) {
    if (typeof node === 'string') {
        this.update(node.trim());
    }
}, context => context.params.query);

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

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

// $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
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) => {
  // ! 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) => {
  // ! 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) => {
  // ! code: func_update
  return validateSchema(update, ajv, options);
  // !end
};
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
// $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);
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
// $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);
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>
validateSchema({}, ajv);

// $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);