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);
}
}
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);
}
// N/A -- only for testing code within frontend bundle
} else if (TestbedConfig.useIPC) {
ElectronRpcManager.initializeImpl({}, TestbedConfig.rpcInterfaces);
} else {
TestbedConfig.cloudRpc = BentleyCloudRpcManager.initializeImpl(TestbedConfig.cloudRpcParams, TestbedConfig.rpcInterfaces);
TestbedConfig.initializeBentleyCloudCommon();
}
ElectronRpcManager.initializeImpl({}, [TestRpcInterface3]);
// RPC transport testing
RpcManager.registerImpl(RpcWebTransportTest, RpcTransportTestImpl);
RpcManager.registerImpl(RpcElectronTransportTest, RpcTransportTestImpl);
RpcManager.registerImpl(RpcMobileTransportTest, RpcTransportTestImpl);
BentleyCloudRpcManager.initializeImpl(TestbedConfig.cloudRpcParams, [RpcWebTransportTest]);
ElectronRpcManager.initializeImpl({}, [RpcElectronTransportTest]);
MobileRpcManager.initializeImpl([RpcMobileTransportTest]);
}
cert: fs.readFileSync(serverConfig.certFile),
};
} catch (_err) { }
}
if (serverConfig === undefined) {
setupStandaloneConfiguration();
serverConfig = { port: 3001, baseUrl: "https://localhost" };
} else {
}
Logger.logTrace("SVT", `config = ${JSON.stringify(serverConfig)}`);
// Set up the ability to serve the supported rpcInterfaces via web requests
const cloudConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "display-test-app", version: "v1.0" } }, getRpcInterfaces());
const app = express();
app.use(bodyParser.text());
// 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.get("/v3/swagger.json", (req, res) => cloudConfig.protocol.handleOpenApiDescriptionRequest(req, res));