-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackendServer.ts
20 lines (18 loc) · 1.07 KB
/
BackendServer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
// tslint:disable:no-console
import { RpcInterfaceDefinition, BentleyCloudRpcManager } from "@bentley/imodeljs-common";
import { IModelJsExpressServer } from "@bentley/express-server";
/**
* 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);
console.log("RPC backend for simple-viewer-app listening on port " + port);
}