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


TypeScript Server.config方法代码示例

本文整理汇总了TypeScript中hapi.Server.config方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Server.config方法的具体用法?TypeScript Server.config怎么用?TypeScript Server.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hapi.Server的用法示例。


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

示例1: initSpacesOnRequestInterceptor

export function initSpacesOnRequestInterceptor(server: Server) {
  const serverBasePath: string = server.config().get('server.basePath');

  server.ext('onRequest', async function spacesOnRequestHandler(request: any, h: any) {
    const path = request.path;

    // If navigating within the context of a space, then we store the Space's URL Context on the request,
    // and rewrite the request to not include the space identifier in the URL.
    const spaceId = getSpaceIdFromPath(path, serverBasePath);

    if (spaceId !== DEFAULT_SPACE_ID) {
      const reqBasePath = `/s/${spaceId}`;
      request.setBasePath(reqBasePath);

      const newLocation = path.substr(reqBasePath.length) || '/';

      const newUrl = {
        ...request.url,
        path: newLocation,
        pathname: newLocation,
        href: newLocation,
      };

      request.setUrl(newUrl);
    }

    return h.continue;
  });
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: createAuthorizationService

export function createAuthorizationService(
  server: Server,
  securityXPackFeature: XPackFeature,
  xpackMainPlugin: XPackMainPlugin,
  spaces: OptionalPlugin<SpacesPlugin>
): AuthorizationService {
  const shieldClient = getClient(server);
  const config = server.config();

  const actions = actionsFactory(config);
  const application = `${APPLICATION_PREFIX}${config.get('kibana.index')}`;
  const checkPrivilegesWithRequest = checkPrivilegesWithRequestFactory(
    actions,
    application,
    shieldClient
  );
  const checkPrivilegesDynamicallyWithRequest = checkPrivilegesDynamicallyWithRequestFactory(
    checkPrivilegesWithRequest,
    spaces
  );
  const mode = authorizationModeFactory(securityXPackFeature);
  const privileges = privilegesFactory(actions, xpackMainPlugin);

  return {
    actions,
    application,
    checkPrivilegesWithRequest,
    checkPrivilegesDynamicallyWithRequest,
    mode,
    privileges,
  };
}
开发者ID:spalger,项目名称:kibana,代码行数:32,代码来源:service.ts

示例3: init

export function init(server: Server, options: any) {
  if (!options.enabled) {
    return;
  }

  const log = new Logger(server);
  const serverOptions = new ServerOptions(options, server.config());
  const xpackMainPlugin: XPackMainPlugin = server.plugins.xpack_main;
  xpackMainPlugin.registerFeature({
    id: 'code',
    name: i18n.translate('xpack.code.featureRegistry.codeFeatureName', {
      defaultMessage: 'Code',
    }),
    icon: 'codeApp',
    navLinkId: 'code',
    app: ['code', 'kibana'],
    catalogue: [], // TODO add catalogue here
    privileges: {
      all: {
        api: ['code_user', 'code_admin'],
        savedObject: {
          all: [],
          read: ['config'],
        },
        ui: ['show', 'user', 'admin'],
      },
      read: {
        api: ['code_user'],
        savedObject: {
          all: [],
          read: ['config'],
        },
        ui: ['show', 'user'],
      },
    },
  });

  // @ts-ignore
  const kbnServer = this.kbnServer;
  kbnServer.ready().then(async () => {
    const serverUuid = await retryUntilAvailable(() => getServerUuid(server), 50);
    // enable security check in routes
    const codeNodeUrl = serverOptions.codeNodeUrl;
    if (codeNodeUrl) {
      const codeNodeUuid = (await retryUntilAvailable(
        async () => await getCodeNodeUuid(codeNodeUrl, log),
        5000
      )) as string;
      if (codeNodeUuid === serverUuid) {
        await initCodeNode(server, serverOptions, log);
      } else {
        await initNonCodeNode(codeNodeUrl, server, serverOptions, log);
      }
    } else {
      // codeNodeUrl not set, single node mode
      await initCodeNode(server, serverOptions, log);
    }
  });
}
开发者ID:elastic,项目名称:kibana,代码行数:59,代码来源:init.ts

示例4: getServerUuid

function getServerUuid(server: Server): Promise<string> {
  const uid = server.config().get('server.uuid') as string;
  return Promise.resolve(uid);
}
开发者ID:elastic,项目名称:kibana,代码行数:4,代码来源:init.ts

示例5: initCodeNode

async function initCodeNode(server: Server, serverOptions: ServerOptions, log: Logger) {
  log.info('Initializing Code plugin as code-node.');
  const queueIndex: string = server.config().get('xpack.code.queueIndex');
  const queueTimeout: number = server.config().get('xpack.code.queueTimeout');
  const devMode: boolean = server.config().get('env.dev');

  const esClient: EsClient = new EsClientWithInternalRequest(server);
  const repoConfigController = new RepositoryConfigController(esClient);

  server.injectUiAppVars('code', () => ({
    enableLangserversDeveloping: devMode,
  }));
  // Enable the developing language servers in development mode.
  if (devMode === true) {
    LanguageServers.push(...LanguageServersDeveloping);
  }

  const installManager = new InstallManager(server, serverOptions);
  const lspService = new LspService(
    '127.0.0.1',
    serverOptions,
    esClient,
    installManager,
    new ServerLoggerFactory(server),
    repoConfigController
  );
  server.events.on('stop', async () => {
    await lspService.shutdown();
  });
  // Initialize indexing factories.
  const lspIndexerFactory = new LspIndexerFactory(lspService, serverOptions, esClient, log);

  const repoIndexInitializerFactory = new RepositoryIndexInitializerFactory(esClient, log);

  // Initialize queue worker cancellation service.
  const cancellationService = new CancellationSerivce();

  // Execute index version checking and try to migrate index data if necessary.
  await tryMigrateIndices(esClient, log);

  // Initialize queue.
  const queue = new Esqueue(queueIndex, {
    client: esClient,
    timeout: queueTimeout,
  });
  const indexWorker = new IndexWorker(
    queue,
    log,
    esClient,
    [lspIndexerFactory],
    serverOptions,
    cancellationService
  ).bind();

  const repoServiceFactory: RepositoryServiceFactory = new RepositoryServiceFactory();

  const cloneWorker = new CloneWorker(
    queue,
    log,
    esClient,
    serverOptions,
    indexWorker,
    repoServiceFactory
  ).bind();
  const deleteWorker = new DeleteWorker(
    queue,
    log,
    esClient,
    serverOptions,
    cancellationService,
    lspService,
    repoServiceFactory
  ).bind();
  const updateWorker = new UpdateWorker(
    queue,
    log,
    esClient,
    serverOptions,
    repoServiceFactory
  ).bind();

  // Initialize schedulers.
  const updateScheduler = new UpdateScheduler(updateWorker, serverOptions, esClient, log);
  const indexScheduler = new IndexScheduler(indexWorker, serverOptions, esClient, log);
  updateScheduler.start();
  if (!serverOptions.disableIndexScheduler) {
    indexScheduler.start();
  }
  // check code node repos on disk
  await checkRepos(cloneWorker, esClient, serverOptions, log);

  const codeServerRouter = new CodeServerRouter(server);
  // Add server routes and initialize the plugin here
  repositoryRoute(
    codeServerRouter,
    cloneWorker,
    deleteWorker,
    indexWorker,
    repoIndexInitializerFactory,
    repoConfigController,
//.........这里部分代码省略.........
开发者ID:elastic,项目名称:kibana,代码行数:101,代码来源:init.ts

示例6: getSpacesUsage

/**
 *
 * @param callCluster
 * @param server
 * @param {boolean} spacesAvailable
 * @return {UsageStats}
 */
async function getSpacesUsage(callCluster: any, server: Server, spacesAvailable: boolean) {
  if (!spacesAvailable) {
    return {} as UsageStats;
  }

  const index = server.config().get('kibana.index');

  const knownFeatureIds = server.plugins.xpack_main.getFeatures().map(feature => feature.id);

  const resp = await callCluster('search', {
    index,
    body: {
      track_total_hits: true,
      query: {
        term: {
          type: {
            value: 'space',
          },
        },
      },
      aggs: {
        disabledFeatures: {
          terms: {
            field: 'space.disabledFeatures',
            include: knownFeatureIds,
            size: knownFeatureIds.length,
          },
        },
      },
      size: 0,
    },
  });

  const { hits, aggregations } = resp;

  const count = get(hits, 'total.value', 0);
  const disabledFeatureBuckets = get(aggregations, 'disabledFeatures.buckets', []);

  const initialCounts = knownFeatureIds.reduce(
    (acc, featureId) => ({ ...acc, [featureId]: 0 }),
    {}
  );

  const disabledFeatures: Record<string, number> = disabledFeatureBuckets.reduce(
    (acc, { key, doc_count }) => {
      return {
        ...acc,
        [key]: doc_count,
      };
    },
    initialCounts
  );

  const usesFeatureControls = Object.values(disabledFeatures).some(
    disabledSpaceCount => disabledSpaceCount > 0
  );

  return {
    count,
    usesFeatureControls,
    disabledFeatures,
  } as UsageStats;
}
开发者ID:,项目名称:,代码行数:70,代码来源:


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