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


TypeScript joi.boolean函数代码示例

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


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

示例1: registerDeprecationLoggingRoutes

export function registerDeprecationLoggingRoutes(server: Legacy.Server) {
  const { callWithRequest } = server.plugins.elasticsearch.getCluster('admin');

  server.route({
    path: '/api/upgrade_assistant/deprecation_logging',
    method: 'GET',
    async handler(request) {
      try {
        return await getDeprecationLoggingStatus(callWithRequest, request);
      } catch (e) {
        return Boom.boomify(e, { statusCode: 500 });
      }
    },
  });

  server.route({
    path: '/api/upgrade_assistant/deprecation_logging',
    method: 'PUT',
    options: {
      validate: {
        payload: Joi.object({
          isEnabled: Joi.boolean(),
        }),
      },
    },
    async handler(request) {
      try {
        const { isEnabled } = request.payload as { isEnabled: boolean };
        return await setDeprecationLogging(callWithRequest, request, isEnabled);
      } catch (e) {
        return Boom.boomify(e, { statusCode: 500 });
      }
    },
  });
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:35,代码来源:deprecation_logging.ts

示例2: upgradeAssistant

export function upgradeAssistant(kibana: any) {
  return new kibana.Plugin({
    id: 'upgrade_assistant',
    configPrefix: 'xpack.upgrade_assistant',
    require: ['elasticsearch'],
    uiExports: {
      managementSections: ['plugins/upgrade_assistant'],
      savedObjectSchemas: {
        'upgrade-assistant-reindex-operation': {
          isNamespaceAgnostic: true,
        },
        'upgrade-assistant-telemetry': {
          isNamespaceAgnostic: true,
        },
      },
      styleSheetPaths: resolve(__dirname, 'public/index.scss'),
      mappings,
    },
    publicDir: resolve(__dirname, 'public'),

    config() {
      return Joi.object({
        enabled: Joi.boolean().default(true),
      }).default();
    },

    init(server: Legacy.Server) {
      // Add server routes and initialize the plugin here
      initServer(server);
    },
  });
}
开发者ID:njd5475,项目名称:kibana,代码行数:32,代码来源:index.ts

示例3: createUser

export function createUser(req: Request, res: Response, next: NextFunction) {
  const schema = Joi.object().keys({
    name: Joi.string().min(3).required(),
    email: Joi.string().email().required(),
    password: Joi.string().required().regex(passwordRegex),
    agreeTos: Joi.boolean().only(true).required(),
    referral: Joi.string().email().options({
      language: {
        key: '{{!label}}',
        string: {
          email: 'Not valid referral code'
        }
      }
    }).label(' ') // Joi does not allow empty label but space is working
  });

  if (req.body.referral) {
    req.body.referral = base64decode(req.body.referral);
  }

  const result = Joi.validate(req.body, schema, options);

  if (result.error) {
    return res.status(422).json(result);
  } else {
    return next();
  }
}
开发者ID:Norestlabs-Mariya,项目名称:backend-ico-dashboard,代码行数:28,代码来源:request.validation.ts

示例4: it

 it("should annotate the class property", function () {
     const metadata = Reflect.getMetadata(WORKING_SCHEMA_KEY, MyClass.prototype);
     const expected = {
         myProperty: Joi.boolean()
     };
     assert.deepEqual(metadata, expected);
 });
开发者ID:laurence-myers,项目名称:tsdv-joi,代码行数:7,代码来源:boolean.ts

示例5: handler

export const createResolveImportErrorsRoute = (
  prereqs: Prerequisites,
  server: Hapi.Server,
  supportedTypes: string[]
) => ({
  path: '/api/saved_objects/_resolve_import_errors',
  method: 'POST',
  config: {
    pre: [prereqs.getSavedObjectsClient],
    payload: {
      maxBytes: server.config().get('savedObjects.maxImportPayloadBytes'),
      output: 'stream',
      allow: 'multipart/form-data',
    },
    validate: {
      payload: Joi.object({
        file: Joi.object().required(),
        retries: Joi.array()
          .items(
            Joi.object({
              type: Joi.string().required(),
              id: Joi.string().required(),
              overwrite: Joi.boolean().default(false),
              replaceReferences: Joi.array()
                .items(
                  Joi.object({
                    type: Joi.string().required(),
                    from: Joi.string().required(),
                    to: Joi.string().required(),
                  })
                )
                .default([]),
            })
          )
          .required(),
      }).default(),
    },
  },
  async handler(request: ImportRequest) {
    const { savedObjectsClient } = request.pre;
    const { filename } = request.payload.file.hapi;
    const fileExtension = extname(filename).toLowerCase();

    if (fileExtension !== '.ndjson') {
      return Boom.badRequest(`Invalid file extension ${fileExtension}`);
    }

    return await resolveImportErrors({
      supportedTypes,
      savedObjectsClient,
      readStream: request.payload.file,
      retries: request.payload.retries,
      objectLimit: request.server.config().get('savedObjects.maxImportExportSize'),
    });
  },
});
开发者ID:elastic,项目名称:kibana,代码行数:56,代码来源:resolve_import_errors.ts

示例6: handler

export const createExportRoute = (
  prereqs: Prerequisites,
  server: Hapi.Server,
  supportedTypes: string[]
) => ({
  path: '/api/saved_objects/_export',
  method: 'POST',
  config: {
    pre: [prereqs.getSavedObjectsClient],
    validate: {
      payload: Joi.object()
        .keys({
          type: Joi.array()
            .items(Joi.string().valid(supportedTypes))
            .single()
            .optional(),
          objects: Joi.array()
            .items({
              type: Joi.string()
                .valid(supportedTypes)
                .required(),
              id: Joi.string().required(),
            })
            .max(server.config().get('savedObjects.maxImportExportSize'))
            .optional(),
          includeReferencesDeep: Joi.boolean().default(false),
        })
        .xor('type', 'objects')
        .default(),
    },
    async handler(request: ExportRequest, h: Hapi.ResponseToolkit) {
      const { savedObjectsClient } = request.pre;
      const docsToExport = await getSortedObjectsForExport({
        savedObjectsClient,
        types: request.payload.type,
        objects: request.payload.objects,
        exportSizeLimit: server.config().get('savedObjects.maxImportExportSize'),
        includeReferencesDeep: request.payload.includeReferencesDeep,
      });
      return h
        .response(docsToExport.map(doc => stringify(doc)).join('\n'))
        .header('Content-Disposition', `attachment; filename="export.ndjson"`)
        .header('Content-Type', 'application/ndjson');
    },
  },
});
开发者ID:elastic,项目名称:kibana,代码行数:46,代码来源:export.ts

示例7: handler

export const createCreateRoute = (prereqs: Prerequisites) => {
  return {
    path: '/api/saved_objects/{type}/{id?}',
    method: 'POST',
    options: {
      pre: [prereqs.getSavedObjectsClient],
      validate: {
        query: Joi.object()
          .keys({
            overwrite: Joi.boolean().default(false),
          })
          .default(),
        params: Joi.object()
          .keys({
            type: Joi.string().required(),
            id: Joi.string(),
          })
          .required(),
        payload: Joi.object({
          attributes: Joi.object().required(),
          migrationVersion: Joi.object().optional(),
          references: Joi.array()
            .items(
              Joi.object().keys({
                name: Joi.string().required(),
                type: Joi.string().required(),
                id: Joi.string().required(),
              })
            )
            .default([]),
        }).required(),
      },
      handler(request: CreateRequest) {
        const { savedObjectsClient } = request.pre;
        const { type, id } = request.params;
        const { overwrite } = request.query;
        const { migrationVersion, references } = request.payload;
        const options = { id, overwrite, migrationVersion, references };

        return savedObjectsClient.create(type, request.payload.attributes, options);
      },
    },
  };
};
开发者ID:elastic,项目名称:kibana,代码行数:44,代码来源:create.ts

示例8: registerTelemetryRoutes

export function registerTelemetryRoutes(server: UpgradeAssistantTelemetryServer) {
  server.route({
    path: '/api/upgrade_assistant/telemetry/ui_open',
    method: 'PUT',
    options: {
      validate: {
        payload: Joi.object({
          overview: Joi.boolean().default(false),
          cluster: Joi.boolean().default(false),
          indices: Joi.boolean().default(false),
        }),
      },
    },
    async handler(request) {
      try {
        return await upsertUIOpenOption(server, request);
      } catch (e) {
        return Boom.boomify(e, { statusCode: 500 });
      }
    },
  });

  server.route({
    path: '/api/upgrade_assistant/telemetry/ui_reindex',
    method: 'PUT',
    options: {
      validate: {
        payload: Joi.object({
          close: Joi.boolean().default(false),
          open: Joi.boolean().default(false),
          start: Joi.boolean().default(false),
          stop: Joi.boolean().default(false),
        }),
      },
    },
    async handler(request) {
      try {
        return await upsertUIReindexOption(server, request);
      } catch (e) {
        return Boom.boomify(e, { statusCode: 500 });
      }
    },
  });
}
开发者ID:njd5475,项目名称:kibana,代码行数:44,代码来源:telemetry.ts

示例9: handler

export const createImportRoute = (
  prereqs: Prerequisites,
  server: Hapi.Server,
  supportedTypes: string[]
) => ({
  path: '/api/saved_objects/_import',
  method: 'POST',
  config: {
    pre: [prereqs.getSavedObjectsClient],
    payload: {
      maxBytes: server.config().get('savedObjects.maxImportPayloadBytes'),
      output: 'stream',
      allow: 'multipart/form-data',
    },
    validate: {
      query: Joi.object()
        .keys({
          overwrite: Joi.boolean().default(false),
        })
        .default(),
      payload: Joi.object({
        file: Joi.object().required(),
      }).default(),
    },
  },
  async handler(request: ImportRequest, h: Hapi.ResponseToolkit) {
    const { savedObjectsClient } = request.pre;
    const { filename } = request.payload.file.hapi;
    const fileExtension = extname(filename).toLowerCase();
    if (fileExtension !== '.ndjson') {
      return Boom.badRequest(`Invalid file extension ${fileExtension}`);
    }
    return await importSavedObjects({
      supportedTypes,
      savedObjectsClient,
      readStream: request.payload.file,
      objectLimit: request.server.config().get('savedObjects.maxImportExportSize'),
      overwrite: request.query.overwrite,
    });
  },
});
开发者ID:elastic,项目名称:kibana,代码行数:41,代码来源:import.ts

示例10: upgradeAssistant

export function upgradeAssistant(kibana: any) {
  return new kibana.Plugin({
    id: 'upgrade_assistant',
    require: ['elasticsearch'],
    uiExports: {
      managementSections: ['plugins/upgrade_assistant'],
      styleSheetPaths: resolve(__dirname, 'public/index.scss'),
    },
    publicDir: resolve(__dirname, 'public'),

    config() {
      return Joi.object({
        enabled: Joi.boolean().default(true),
      }).default();
    },

    init(server: Server) {
      // Add server routes and initialize the plugin here
      initServer(server);
    },
  });
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:22,代码来源:index.ts


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