forked from imodeljs/imodeljs-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BackendServer.ts
22 lines (19 loc) · 1.17 KB
/
BackendServer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { Logger } from "@bentley/bentleyjs-core";
import { RpcInterfaceDefinition, BentleyCloudRpcManager } from "@bentley/imodeljs-common";
import { IModelJsExpressServer } from "@bentley/express-server";
import { AppLoggerCategory } from "../../common/configuration";
/**
* Initializes Web Server backend
*/
export default async function initialize(rpcs: RpcInterfaceDefinition[]) {
// tell BentleyCloudRpcManager which RPC interfaces to handle
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "simple-viewer-app", version: "v1.0" } }, rpcs);
const port = Number(process.env.PORT || 3001);
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
Logger.logInfo(AppLoggerCategory.Backend, `RPC backend for simple-viewer-app listening on port ${port}`);
}