How to use the @bentley/config-loader/lib/IModelJsConfig.IModelJsConfig.init function in @bentley/config-loader

To help you get started, we’ve selected a few @bentley/config-loader 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 imodeljs / imodeljs / test-apps / perf-test-app / src / backend / backend.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { IModelHost, IModelHostConfiguration } from "@bentley/imodeljs-backend";
import { Config } from "@bentley/imodeljs-clients";
import { BentleyCloudRpcManager, ElectronRpcConfiguration, ElectronRpcManager, RpcConfiguration } from "@bentley/imodeljs-common";
import { IModelJsExpressServer } from "@bentley/express-server";
import { rpcInterfaces } from "../common/RpcInterfaces";
import "./RpcImpl";

IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;

// Start the backend
const hostConfig = new IModelHostConfiguration();
IModelHost.startup(hostConfig);

Logger.initializeToConsole();
Logger.setLevel("imodeljs-backend.IModelReadRpcImpl", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("imodeljs-backend.IModelDb", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("Performance", LogLevel.Error);  // Change to Info to capture

async function init() {
  if (ElectronRpcConfiguration.isElectron) {
    ElectronRpcManager.initializeImpl({}, rpcInterfaces);
  } else {
    const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);
github imodeljs / imodeljs / test-apps / testbed / backend / index.ts View on Github external
import * as express from "express";
import * as bodyParser from "body-parser";
import * as WebSocket from "ws";

const mobilePort = process.env.MOBILE_PORT ? parseInt(process.env.MOBILE_PORT, 10) : 4000;
setupMobileMock();

import { IModelHost } from "@bentley/imodeljs-backend";
import { TestbedConfig, TestbedIpcMessage } from "../common/TestbedConfig";
import { TestRpcImpl, TestRpcImpl2, TestRpcImpl3, resetOp8Initializer, TestZeroMajorRpcImpl } from "./TestRpcImpl";
import { CONSTANTS } from "../common/Testbed";
import { RpcConfiguration, IModelReadRpcInterface, HttpServerRequest, HttpServerResponse } from "@bentley/imodeljs-common";
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { Config } from "@bentley/imodeljs-clients";
IModelJsConfig.init(true, true, Config.App);
const compatibleVersion = IModelReadRpcInterface.version;

let pendingsSent = 0;
let pendingResponseQuota = 0;

RpcConfiguration.developmentMode = true;
TestbedConfig.mobilePort = mobilePort;

// tslint:disable-next-line:no-var-requires
const { ipcMain } = require("electron");
ipcMain.on("testbed", handleTestbedCommand);

// Start the backend
IModelHost.startup();

TestRpcImpl.register();
github imodeljs / imodeljs / test-apps / display-test-app / src / backend / backend.ts View on Github external
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { IModelHost, IModelHostConfiguration } from "@bentley/imodeljs-backend";
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelTileRpcInterface, SnapshotIModelRpcInterface, IModelReadRpcInterface, MobileRpcConfiguration } from "@bentley/imodeljs-common";
import * as fs from "fs";
import * as path from "path";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { IModelBankClient, Config } from "@bentley/imodeljs-clients";
import { UrlFileHandler } from "@bentley/imodeljs-clients-backend";
import { SVTConfiguration } from "../common/SVTConfiguration";
import "./SVTRpcImpl"; // just to get the RPC implementation registered
import SVTRpcInterface from "../common/SVTRpcInterface";
import { FakeTileCacheService } from "./FakeTileCacheService";

IModelJsConfig.init(true /* suppress exception */, true /* suppress error message */, Config.App);
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // (needed temporarily to use self-signed cert to communicate with iModelBank via https)

export function getRpcInterfaces() {
  return [IModelTileRpcInterface, SnapshotIModelRpcInterface, IModelReadRpcInterface, SVTRpcInterface];
}

function setupStandaloneConfiguration(): SVTConfiguration {
  const configuration: SVTConfiguration = {};
  if (MobileRpcConfiguration.isMobileBackend)
    return configuration;

  // Currently display-test-app ONLY supports opening files from local disk - i.e., "standalone" mode.
  // At some point we will reinstate ability to open from hub.
  configuration.standalone = true;
  configuration.iModelName = process.env.SVT_STANDALONE_FILENAME;
  configuration.standalonePath = process.env.SVT_STANDALONE_FILEPATH; // optional (browser-use only)
github imodeljs / imodeljs / test-apps / display-performance-test-app / src / backend / backend.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { IModelHost, IModelHostConfiguration, IModelJsFs } from "@bentley/imodeljs-backend";
import { IModelTileRpcInterface, SnapshotIModelRpcInterface, IModelReadRpcInterface, MobileRpcConfiguration } from "@bentley/imodeljs-common";
import * as path from "path";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { IModelBankClient, Config } from "@bentley/imodeljs-clients";
import { UrlFileHandler } from "@bentley/imodeljs-clients-backend";
import { SVTConfiguration } from "../common/SVTConfiguration";
import "./DisplayPerfRpcImpl"; // just to get the RPC implementation registered
import DisplayPerfRpcInterface from "../common/DisplayPerfRpcInterface";

IModelJsConfig.init(true /* suppress exception */, true /* suppress error message */, Config.App);
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // (needed temporarily to use self-signed cert to communicate with iModelBank via https)

export function getRpcInterfaces() {
  return [DisplayPerfRpcInterface, IModelTileRpcInterface, SnapshotIModelRpcInterface, IModelReadRpcInterface];
}

function setupStandaloneConfiguration() {
  const filename = process.env.SVT_STANDALONE_FILENAME;
  if (filename !== undefined) {
    const configuration: any = {};
    configuration.standalone = true;
    configuration.standalonePath = process.env.SVT_STANDALONE_FILEPATH; // optional (browser-use only)
    configuration.viewName = process.env.SVT_STANDALONE_VIEWNAME; // optional
    configuration.iModelName = filename;
    const configPathname = path.normalize(path.join(__dirname, "../webresources", "configuration.json"));
    IModelJsFs.writeFileSync(configPathname, JSON.stringify(configuration));
github imodeljs / imodeljs / integration-tests / core / src / backend / backend.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { IModelHost, IModelHostConfiguration } from "@bentley/imodeljs-backend";
import { Config } from "@bentley/imodeljs-clients";
import { IModelJsExpressServer } from "@bentley/express-server";
import { BentleyCloudRpcManager, ElectronRpcConfiguration, ElectronRpcManager, RpcConfiguration } from "@bentley/imodeljs-common";
import { rpcInterfaces } from "../common/RpcInterfaces";
import "./RpcImpl";

IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;

// Start the backend
const hostConfig = new IModelHostConfiguration();
hostConfig.concurrentQuery.concurrent = 2;
hostConfig.concurrentQuery.pollInterval = 5;
IModelHost.startup(hostConfig);

Logger.initializeToConsole();
Logger.setLevel("imodeljs-backend.IModelReadRpcImpl", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("imodeljs-backend.IModelDb", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("Performance", LogLevel.Error);  // Change to Info to capture

async function init() {
  if (ElectronRpcConfiguration.isElectron) {
    ElectronRpcManager.initializeImpl({}, rpcInterfaces);
github imodeljs / imodeljs / test-apps / ui-test-app / src / backend / main.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import * as path from "path";
import { app as electron } from "electron";
import { IModelHost } from "@bentley/imodeljs-backend";
import { RpcInterfaceDefinition } from "@bentley/imodeljs-common";
import { Presentation } from "@bentley/presentation-backend";
import getSupportedRpcs from "../common/rpcs";

import { Config } from "@bentley/imodeljs-clients";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { initializeLogging, setupSnapshotConfiguration } from "./web/BackendServer";

IModelJsConfig.init(true /*suppress error*/, true /* suppress message */, Config.App);

if (!electron) {
  initializeLogging();
  setupSnapshotConfiguration();
}

// initialize imodeljs-backend
IModelHost.startup();

// initialize presentation-backend
Presentation.initialize({
  // Specify location of where application's presentation rule sets are located.
  // May be omitted if application doesn't have any presentation rules.
  rulesetDirectories: [path.join("assets", "presentation_rules")],
  enableSchemasPreload: true,
});
github imodeljs / imodeljs / test-apps / presentation-test-app / src / backend / main.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import * as path from "path";
import { app as electron } from "electron";
import { Logger } from "@bentley/bentleyjs-core";
import { IModelHost } from "@bentley/imodeljs-backend";
import { RpcInterfaceDefinition, RpcConfiguration } from "@bentley/imodeljs-common";
import { Config } from "@bentley/imodeljs-clients";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import rpcs from "../common/Rpcs";
import "./SampleRpcImpl"; // just to get the RPC implementation registered

IModelJsConfig.init(true /*suppress error*/, true /* suppress message */, Config.App);

// initialize logging
Logger.initializeToConsole();

// initialize imodeljs-backend
IModelHost.startup();

// __PUBLISH_EXTRACT_START__ Presentation.Backend.Initialization
import { Presentation, PresentationManagerMode } from "@bentley/presentation-backend";

// initialize presentation-backend
Presentation.initialize({
  rulesetDirectories: [path.join("assets", "presentation_rules")],
  localeDirectories: [path.join("assets", "locales")],
  mode: PresentationManagerMode.ReadOnly,
});
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { IModelHost } from "@bentley/imodeljs-backend";
import { RpcConfiguration, IModelReadRpcInterface } from "@bentley/imodeljs-common";
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { Config } from "@bentley/imodeljs-clients";
import { registerBackendCallback } from "@bentley/certa/lib/utils/CallbackUtils";
import { BackendTestCallbacks } from "../common/SideChannels";
import { TestRpcImpl2, resetOp8Initializer } from "./TestRpcImpl";

IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;

// Start the backend
IModelHost.startup();

registerBackendCallback(BackendTestCallbacks.registerTestRpcImpl2Class, () => {
  TestRpcImpl2.register();
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.replaceTestRpcImpl2Instance, () => {
  TestRpcImpl2.instantiate();
  return true;
});
github imodeljs / imodeljs / example-code / snippets / src / backend / IModelTestUtils.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { assert } from "chai";
import { RpcManager, IModelReadRpcInterface } from "@bentley/imodeljs-common";
import { OpenMode, ClientRequestContext } from "@bentley/bentleyjs-core";
import { AccessToken, AuthorizationToken, ImsActiveSecureTokenClient, ImsDelegationSecureTokenClient, ConnectClient, Config, ImsUserCredentials } from "@bentley/imodeljs-clients";
import { IModelDb, IModelHost, IModelHostConfiguration, KnownLocations } from "@bentley/imodeljs-backend";
import { IModelJsFs, IModelJsFsStats } from "@bentley/imodeljs-backend/lib/IModelJsFs";
import * as path from "path";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
IModelJsConfig.init(true /* suppress exception */, false /* suppress error message */, Config.App);

RpcManager.initializeInterface(IModelReadRpcInterface);

export interface IModelTestUtilsOpenOptions {
  copyFilename?: string;
  enableTransactions?: boolean;
  openMode?: OpenMode;
}

/** Test users with various permissions */
export class TestUsers {
  /** User with the typical permissions of the regular/average user - Co-Admin: No, Connect-Services-Admin: No */
  public static get regular(): ImsUserCredentials {
    return {
      email: Config.App.getString("imjs_test_regular_user_name"),
      password: Config.App.getString("imjs_test_regular_user_password"),
github imodeljs / imodeljs / test-apps / presentation-integration-tests / src / IntegrationTests.ts View on Github external
import * as fs from "fs";
import * as path from "path";
import * as cpx from "cpx";
import "@bentley/presentation-frontend/lib/test/_helpers/MockFrontendEnvironment";
import { I18NOptions } from "@bentley/imodeljs-i18n";
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { LoggingNamespaces, RequestPriority } from "@bentley/presentation-common";
import { PresentationProps as PresentationBackendProps } from "@bentley/presentation-backend";
import { PresentationManagerProps as PresentationFrontendProps } from "@bentley/presentation-frontend";
import { NoRenderApp, IModelAppOptions } from "@bentley/imodeljs-frontend";
import { initializeAsync as initializeTesting, terminate as terminateTesting, PresentationTestingInitProps } from "@bentley/presentation-testing";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";

process.env.NODE_ENV = "development";

IModelJsConfig.init(true);

const copyBentleyBackendAssets = (outputDir: string) => {
  const bentleyPackagesPath = "node_modules/@bentley";
  fs.readdirSync(bentleyPackagesPath).map((packageName) => {
    const packagePath = path.resolve(bentleyPackagesPath, packageName);
    return path.join(packagePath, "lib", "assets");
  }).filter((assetsPath) => {
    return fs.existsSync(assetsPath);
  }).forEach((src) => {
    cpx.copySync(`${src}/**/*`, outputDir);
  });
};

const copyBentleyFrontendAssets = (outputDir: string) => {
  const bentleyPackagesPath = "node_modules/@bentley";
  fs.readdirSync(bentleyPackagesPath).map((packageName) => {

@bentley/config-loader

Configuration loader

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis