当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript feathers-hooks-common.disallow函数代码示例

本文整理汇总了TypeScript中feathers-hooks-common.disallow函数的典型用法代码示例。如果您正苦于以下问题:TypeScript disallow函数的具体用法?TypeScript disallow怎么用?TypeScript disallow使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了disallow函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: disallow

const disallowExternal = (hook: BeforeHookContext<DefaultDocument>) => {
  if (hook.path === 'authentication') {
    return hook;
  }

  return disallow('external')(hook);
};
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:7,代码来源:hooks.ts

示例2: debug

import validateInSteamGroup from './validate-in-steam-group';
import validateHours from './validate-hours';

const log = debug('TF2Pickup:users:hooks');
const inviteUserToGroup = promisify(steamCommunity.inviteUserToGroup.bind(steamCommunity));

const hooks: Hooks<User> = {
  before: {
    create: [
      // Validate that the userId is in the steam group when the website is in beta mode
      validateInSteamGroup,
      // Validate the users TF2 hours
      validateHours,
    ],
    remove: disallow(),
  },

  after: {
    create: [
      (hook) => {
        log('Created a new user', {
          userId: hook.result.id,
          data: hook.result,
        });
      },
      // Create the rest of the documents for a userId.
      async (hook: CreateAfterHookContext<User>) => {
        await hook.app.service('user-settings').create({
          id: hook.result.id,
          volume: 0.7,
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:30,代码来源:index.ts

示例3: requireAuth

function requireAuth(
  hook: BeforeHookContext<DefaultDocument>
) {
  if (hook.params.provider === 'external') {
    return auth.hooks.authenticate(['jwt'])(hook);
  }

  return hook;
}

const hooks: Hooks<DefaultDocument> = {
  before: {
    find: requireAuth,
    get: requireAuth,
    // Completely disallow the update hook
    update: disallow(),
    // Disallow every patch, remove, create call from external
    patch: disallowExternal,
    remove: disallowExternal,
    create: disallowExternal,
  },

  error: {
    all(hook) {
      if (hook.error.code === 404) {
        return hook;
      }

      log(
        `Error in '${hook.path}' service method ${hook.method.toUpperCase()}`,
        { error: hook.error },
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:31,代码来源:hooks.ts

示例4: create

import { CreateBeforeHookContext } from '@feathersjs/feathers';
import hooks from 'feathers-hooks-common';
import UserProfile from '@typings/UserProfile';

import getUserData from './get-user-data';

export default {
  before: {
    find: hooks.disallow(),
    remove: hooks.disallow(),
    async create(hook: CreateBeforeHookContext<UserProfile>) {
      const data = await getUserData(hook.data);

      return {
        ...hook,
        data: {
          ...hook.data,
          ...data,
        },
      };
    },
  },
};
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:23,代码来源:hooks.ts


注:本文中的feathers-hooks-common.disallow函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。