Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function init() {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "rpc-integration-test", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3021) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for integration-tests listening on port " + port);
}
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for perf-tests listening on port " + port);
}
}
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "integration-test", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for integration-tests listening on port " + port);
}
}
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for perf-tests listening on port " + port);
}
}
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "integration-test", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for integration-tests listening on port " + port);
}
}
if (arg.split(".").pop() === "json")
DisplayPerfRpcInterface.jsonFilePath = arg;
else if (arg === "chrome" || arg === "edge" || arg === "firefox")
browser = arg;
});
if (serverConfig === undefined) {
setupStandaloneConfiguration();
serverConfig = { port: 3001, baseUrl: "https://localhost" };
} else {
}
// Set up the ability to serve the supported rpcInterfaces via web requests
const cloudConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "display-performance-test-app", version: "v1.0" } }, getRpcInterfaces());
const app = express();
app.use(bodyParser.text({ limit: "50mb" }));
// Enable CORS for all apis
app.all("/*", (_req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "POST, GET");
res.header("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Correlation-Id, X-Session-Id, X-Application-Id, X-Application-Version, X-User-Id");
next();
});
// --------------------------------------------
// Routes
// --------------------------------------------
app.use(express.static(path.resolve(__dirname, "public")));
export default async function initialize(rpcs: RpcInterfaceDefinition[]) {
// tell BentleyCloudRpcManager which RPC interfaces to handle
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "ui-test-app", version: "v1.0" } }, rpcs);
// create a basic express web server
const port = Number(process.env.PORT || 3001);
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
console.log("Web backend for ui-test-app listening on port " + port);
}
iModel.views.iterateViews({ from: "BisCore.SpatialViewDefinition" }, (view: ViewDefinition) => {
if (!view.isSpatialView())
return true;
// Create a new display style.
const vf = new ViewFlags();
vf.renderMode = RenderMode.SmoothShade;
vf.cameraLights = true;
const bgColor = new ColorDef("rgb(127, 127, 127)");
const displayStyleId = DisplayStyle3d.insert(iModel, view.model, "Schedule View Style", { viewFlags: vf, backgroundColor: bgColor, scheduleScript: script });
iModel.views.setDefaultViewId(SpatialViewDefinition.insertWithCamera(iModel, view.model, "Schedule View", view.modelSelectorId, view.categorySelectorId, displayStyleId, iModel.projectExtents, StandardViewIndex.Iso));
return true;
});
return true;
public async queryViewProps(imodel: IModelConnection, refresh?: boolean): Promise {
if (!this._viewDefCache || refresh) {
const params: ViewQueryParams = {};
params.from = ViewState.classFullName; // use "BisCore.ViewDefinition" as default class name
params.where = "";
const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(imodel.iModelToken.toJSON(), params);
this._viewDefCache = viewProps as ViewDefinitionProps[];
}
return this._viewDefCache;
}
private initOverrides(): FeatureSymbology.Overrides {
const ovrs = new FeatureSymbology.Overrides(this.viewport);
ovrs.neverDrawn.clear();
ovrs.alwaysDrawn.clear();
ovrs.setAlwaysDrawnSet(this.changedElems.deleted, true, false); // really "only-drawn" - only draw our deleted elements - unless their subcategory is turned off.
const red = ColorDef.from(0xff, 0, 0, changedTransparency);
ovrs.setDefaultOverrides(FeatureSymbology.Appearance.fromRgba(red));
return ovrs;
}