@itwin/express-server 4.0.0-dev.8 → 4.0.0-dev.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,48 @@
1
1
  # Change Log - @itwin/express-server
2
2
 
3
- This log was last generated on Thu, 26 Jan 2023 22:53:27 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 12 Apr 2023 13:12:42 GMT and should not be manually modified.
4
+
5
+ ## 3.7.2
6
+ Wed, 12 Apr 2023 13:12:42 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.7.1
11
+ Mon, 03 Apr 2023 15:15:37 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 3.7.0
16
+ Wed, 29 Mar 2023 15:02:27 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 3.6.3
21
+ Mon, 27 Mar 2023 16:26:47 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 3.6.2
26
+ Fri, 17 Mar 2023 17:52:32 GMT
27
+
28
+ _Version update only_
29
+
30
+ ## 3.6.1
31
+ Fri, 24 Feb 2023 22:00:48 GMT
32
+
33
+ _Version update only_
34
+
35
+ ## 3.6.0
36
+ Wed, 08 Feb 2023 14:58:40 GMT
37
+
38
+ ### Updates
39
+
40
+ - React to RPC deprecations.
41
+
42
+ ## 3.5.6
43
+ Fri, 24 Feb 2023 16:02:47 GMT
44
+
45
+ _Version update only_
4
46
 
5
47
  ## 3.5.5
6
48
  Thu, 26 Jan 2023 22:53:27 GMT
@@ -1,43 +1,43 @@
1
- /// <reference types="node" />
2
- import { Server as HttpServer } from "http";
3
- import { RpcConfiguration, WebAppRpcProtocol } from "@itwin/core-common";
4
- /**
5
- * Options for configuring IModelJsExpressServer.
6
- * @public
7
- */
8
- export interface IModelJsExpressServerConfig {
9
- uploadLimit: string;
10
- }
11
- /**
12
- * An express web server with some reasonable defaults for web applications built with @bentley/webpack-tools.
13
- * @note This server is not designed to be a hardened, secure endpoint on the public internet.
14
- * It is intended to participate in a private HTTP exchange with a public-facing routing and provisioning infrastructure
15
- * that should be supplied by the application's deployment environment.
16
- * @public
17
- */
18
- export declare class IModelJsExpressServer {
19
- /** The default configuration for servers. */
20
- static readonly defaults: IModelJsExpressServerConfig;
21
- private _protocol;
22
- private _config;
23
- protected _app: import("express").Application;
24
- /** @alpha */
25
- get rpcConfiguration(): RpcConfiguration;
26
- constructor(protocol: WebAppRpcProtocol, config?: IModelJsExpressServerConfig);
27
- protected _configureMiddleware(): void;
28
- protected _configureHeaders(): void;
29
- protected _configureRoutes(): void;
30
- /**
31
- * Configure the express application with necessary headers, routes, and middleware, then starts listening on the given port.
32
- * @param port The port to listen on
33
- */
34
- initialize(port: number | string): Promise<HttpServer>;
35
- }
36
- /**
37
- * @alpha
38
- */
39
- export declare class WebEditServer extends IModelJsExpressServer {
40
- protected _configureRoutes(): void;
41
- constructor(protocol: WebAppRpcProtocol, config?: IModelJsExpressServerConfig);
42
- }
1
+ /// <reference types="node" />
2
+ import { Server as HttpServer } from "http";
3
+ import { RpcConfiguration, WebAppRpcProtocol } from "@itwin/core-common";
4
+ /**
5
+ * Options for configuring IModelJsExpressServer.
6
+ * @public
7
+ */
8
+ export interface IModelJsExpressServerConfig {
9
+ uploadLimit: string;
10
+ }
11
+ /**
12
+ * An express web server with some reasonable defaults for web applications built with @bentley/webpack-tools.
13
+ * @note This server is not designed to be a hardened, secure endpoint on the public internet.
14
+ * It is intended to participate in a private HTTP exchange with a public-facing routing and provisioning infrastructure
15
+ * that should be supplied by the application's deployment environment.
16
+ * @public
17
+ */
18
+ export declare class IModelJsExpressServer {
19
+ /** The default configuration for servers. */
20
+ static readonly defaults: IModelJsExpressServerConfig;
21
+ private _protocol;
22
+ private _config;
23
+ protected _app: import("express").Application;
24
+ /** @alpha */
25
+ get rpcConfiguration(): RpcConfiguration;
26
+ constructor(protocol: WebAppRpcProtocol, config?: IModelJsExpressServerConfig);
27
+ protected _configureMiddleware(): void;
28
+ protected _configureHeaders(): void;
29
+ protected _configureRoutes(): void;
30
+ /**
31
+ * Configure the express application with necessary headers, routes, and middleware, then starts listening on the given port.
32
+ * @param port The port to listen on
33
+ */
34
+ initialize(port: number | string): Promise<HttpServer>;
35
+ }
36
+ /**
37
+ * @alpha
38
+ */
39
+ export declare class WebEditServer extends IModelJsExpressServer {
40
+ protected _configureRoutes(): void;
41
+ constructor(protocol: WebAppRpcProtocol, config?: IModelJsExpressServerConfig);
42
+ }
43
43
  //# sourceMappingURL=ExpressServer.d.ts.map
@@ -1,83 +1,83 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebEditServer = exports.IModelJsExpressServer = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- const express = require("express");
9
- const enableWs = require("express-ws");
10
- const core_common_1 = require("@itwin/core-common");
11
- const core_backend_1 = require("@itwin/core-backend");
12
- /**
13
- * An express web server with some reasonable defaults for web applications built with @bentley/webpack-tools.
14
- * @note This server is not designed to be a hardened, secure endpoint on the public internet.
15
- * It is intended to participate in a private HTTP exchange with a public-facing routing and provisioning infrastructure
16
- * that should be supplied by the application's deployment environment.
17
- * @public
18
- */
19
- class IModelJsExpressServer {
20
- constructor(protocol, config = IModelJsExpressServer.defaults) {
21
- this._app = express();
22
- this._protocol = protocol;
23
- this._config = config;
24
- }
25
- /** @alpha */
26
- get rpcConfiguration() { return this._protocol.configuration; }
27
- _configureMiddleware() {
28
- this._app.use(express.text({ limit: this._config.uploadLimit }));
29
- this._app.use(express.raw({ limit: this._config.uploadLimit }));
30
- }
31
- _configureHeaders() {
32
- // enable CORS for all apis
33
- this._app.all("/**", (_req, res, next) => {
34
- res.header("Access-Control-Allow-Origin", core_common_1.BentleyCloudRpcConfiguration.accessControl.allowOrigin);
35
- res.header("Access-Control-Allow-Methods", core_common_1.BentleyCloudRpcConfiguration.accessControl.allowMethods);
36
- res.header("Access-Control-Allow-Headers", core_common_1.BentleyCloudRpcConfiguration.accessControl.allowHeaders);
37
- next();
38
- });
39
- }
40
- _configureRoutes() {
41
- this._app.get("/v3/swagger.json", (req, res) => this._protocol.handleOpenApiDescriptionRequest(req, res));
42
- this._app.post("*", async (req, res) => this._protocol.handleOperationPostRequest(req, res));
43
- this._app.get(/\/imodel\//, async (req, res) => this._protocol.handleOperationGetRequest(req, res));
44
- this._app.get("/ping", async (_req, res) => res.status(200).send("Success"));
45
- // for all HTTP requests, identify the server.
46
- this._app.use("*", (_req, resp) => {
47
- resp.send("<h1>IModelJs RPC Server</h1>");
48
- });
49
- }
50
- /**
51
- * Configure the express application with necessary headers, routes, and middleware, then starts listening on the given port.
52
- * @param port The port to listen on
53
- */
54
- async initialize(port) {
55
- this._configureMiddleware();
56
- this._configureHeaders();
57
- this._configureRoutes();
58
- this._app.set("port", port);
59
- return new Promise((resolve) => {
60
- const server = this._app.listen(this._app.get("port"), () => resolve(server));
61
- });
62
- }
63
- }
64
- exports.IModelJsExpressServer = IModelJsExpressServer;
65
- /** The default configuration for servers. */
66
- IModelJsExpressServer.defaults = {
67
- uploadLimit: "5mb",
68
- };
69
- /**
70
- * @alpha
71
- */
72
- class WebEditServer extends IModelJsExpressServer {
73
- _configureRoutes() {
74
- this._app.ws("/ipc", (ws, _req) => core_backend_1.LocalhostIpcHost.connect(ws));
75
- super._configureRoutes();
76
- }
77
- constructor(protocol, config = IModelJsExpressServer.defaults) {
78
- super(protocol, config);
79
- enableWs(this._app);
80
- }
81
- }
82
- exports.WebEditServer = WebEditServer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebEditServer = exports.IModelJsExpressServer = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const express = require("express");
9
+ const enableWs = require("express-ws");
10
+ const core_common_1 = require("@itwin/core-common");
11
+ const core_backend_1 = require("@itwin/core-backend");
12
+ /**
13
+ * An express web server with some reasonable defaults for web applications built with @bentley/webpack-tools.
14
+ * @note This server is not designed to be a hardened, secure endpoint on the public internet.
15
+ * It is intended to participate in a private HTTP exchange with a public-facing routing and provisioning infrastructure
16
+ * that should be supplied by the application's deployment environment.
17
+ * @public
18
+ */
19
+ class IModelJsExpressServer {
20
+ /** @alpha */
21
+ get rpcConfiguration() { return this._protocol.configuration; }
22
+ constructor(protocol, config = IModelJsExpressServer.defaults) {
23
+ this._app = express();
24
+ this._protocol = protocol;
25
+ this._config = config;
26
+ }
27
+ _configureMiddleware() {
28
+ this._app.use(express.text({ limit: this._config.uploadLimit }));
29
+ this._app.use(express.raw({ limit: this._config.uploadLimit }));
30
+ }
31
+ _configureHeaders() {
32
+ // enable CORS for all apis
33
+ this._app.all("/**", (_req, res, next) => {
34
+ res.header("Access-Control-Allow-Origin", core_common_1.BentleyCloudRpcConfiguration.accessControl.allowOrigin);
35
+ res.header("Access-Control-Allow-Methods", core_common_1.BentleyCloudRpcConfiguration.accessControl.allowMethods);
36
+ res.header("Access-Control-Allow-Headers", core_common_1.BentleyCloudRpcConfiguration.accessControl.allowHeaders);
37
+ next();
38
+ });
39
+ }
40
+ _configureRoutes() {
41
+ this._app.get("/v3/swagger.json", (req, res) => this._protocol.handleOpenApiDescriptionRequest(req, res));
42
+ this._app.post("*", async (req, res) => this._protocol.handleOperationPostRequest(req, res));
43
+ this._app.get(/\/imodel\//, async (req, res) => this._protocol.handleOperationGetRequest(req, res));
44
+ this._app.get("/ping", async (_req, res) => res.status(200).send("Success"));
45
+ // for all HTTP requests, identify the server.
46
+ this._app.use("*", (_req, resp) => {
47
+ resp.send("<h1>IModelJs RPC Server</h1>");
48
+ });
49
+ }
50
+ /**
51
+ * Configure the express application with necessary headers, routes, and middleware, then starts listening on the given port.
52
+ * @param port The port to listen on
53
+ */
54
+ async initialize(port) {
55
+ this._configureMiddleware();
56
+ this._configureHeaders();
57
+ this._configureRoutes();
58
+ this._app.set("port", port);
59
+ return new Promise((resolve) => {
60
+ const server = this._app.listen(this._app.get("port"), () => resolve(server));
61
+ });
62
+ }
63
+ }
64
+ /** The default configuration for servers. */
65
+ IModelJsExpressServer.defaults = {
66
+ uploadLimit: "5mb",
67
+ };
68
+ exports.IModelJsExpressServer = IModelJsExpressServer;
69
+ /**
70
+ * @alpha
71
+ */
72
+ class WebEditServer extends IModelJsExpressServer {
73
+ _configureRoutes() {
74
+ this._app.ws("/ipc", (ws, _req) => core_backend_1.LocalhostIpcHost.connect(ws));
75
+ super._configureRoutes();
76
+ }
77
+ constructor(protocol, config = IModelJsExpressServer.defaults) {
78
+ super(protocol, config);
79
+ enableWs(this._app);
80
+ }
81
+ }
82
+ exports.WebEditServer = WebEditServer;
83
83
  //# sourceMappingURL=ExpressServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressServer.js","sourceRoot":"","sources":["../../src/ExpressServer.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAAmC;AACnC,uCAAuC;AAEvC,oDAAuG;AACvG,sDAAuD;AAUvD;;;;;;GAMG;AACH,MAAa,qBAAqB;IAahC,YAAY,QAA2B,EAAE,MAAM,GAAG,qBAAqB,CAAC,QAAQ;QALtE,SAAI,GAAkC,OAAO,EAAE,CAAC;QAMxD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAND,aAAa;IACb,IAAW,gBAAgB,KAAuB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IAO9E,oBAAoB;QAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,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QAAQ,EAAE,MAAM,CAAC,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF;AAVD,sCAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport * as express from \"express\";\r\nimport * as enableWs from \"express-ws\";\r\nimport { Server as HttpServer } from \"http\";\r\nimport { BentleyCloudRpcConfiguration, RpcConfiguration, WebAppRpcProtocol } from \"@itwin/core-common\";\r\nimport { LocalhostIpcHost } from \"@itwin/core-backend\";\r\n\r\n/**\r\n * Options for configuring IModelJsExpressServer.\r\n * @public\r\n */\r\nexport interface IModelJsExpressServerConfig {\r\n uploadLimit: string;\r\n}\r\n\r\n/**\r\n * An express web server with some reasonable defaults for web applications built with @bentley/webpack-tools.\r\n * @note This server is not designed to be a hardened, secure endpoint on the public internet.\r\n * It is intended to participate in a private HTTP exchange with a public-facing routing and provisioning infrastructure\r\n * that should be supplied by the application's deployment environment.\r\n * @public\r\n */\r\nexport class IModelJsExpressServer {\r\n /** The default configuration for servers. */\r\n public static readonly defaults: IModelJsExpressServerConfig = {\r\n uploadLimit: \"5mb\",\r\n };\r\n\r\n private _protocol: WebAppRpcProtocol;\r\n private _config: IModelJsExpressServerConfig;\r\n protected _app: import(\"express\").Application = express();\r\n\r\n /** @alpha */\r\n public get rpcConfiguration(): RpcConfiguration { return this._protocol.configuration; }\r\n\r\n constructor(protocol: WebAppRpcProtocol, config = IModelJsExpressServer.defaults) {\r\n this._protocol = protocol;\r\n this._config = config;\r\n }\r\n\r\n protected _configureMiddleware() {\r\n this._app.use(express.text({ limit: this._config.uploadLimit }));\r\n this._app.use(express.raw({ limit: this._config.uploadLimit }));\r\n }\r\n\r\n protected _configureHeaders() {\r\n // enable CORS for all apis\r\n this._app.all(\"/**\", (_req, res, next) => {\r\n res.header(\"Access-Control-Allow-Origin\", BentleyCloudRpcConfiguration.accessControl.allowOrigin);\r\n res.header(\"Access-Control-Allow-Methods\", BentleyCloudRpcConfiguration.accessControl.allowMethods);\r\n res.header(\"Access-Control-Allow-Headers\", BentleyCloudRpcConfiguration.accessControl.allowHeaders);\r\n next();\r\n });\r\n }\r\n\r\n protected _configureRoutes() {\r\n this._app.get(\"/v3/swagger.json\", (req, res) => this._protocol.handleOpenApiDescriptionRequest(req, res));\r\n this._app.post(\"*\", async (req, res) => this._protocol.handleOperationPostRequest(req, res));\r\n this._app.get(/\\/imodel\\//, async (req, res) => this._protocol.handleOperationGetRequest(req, res));\r\n this._app.get(\"/ping\", async (_req, res) => res.status(200).send(\"Success\"));\r\n // for all HTTP requests, identify the server.\r\n this._app.use(\"*\", (_req, resp) => {\r\n resp.send(\"<h1>IModelJs RPC Server</h1>\");\r\n });\r\n }\r\n\r\n /**\r\n * Configure the express application with necessary headers, routes, and middleware, then starts listening on the given port.\r\n * @param port The port to listen on\r\n */\r\n public async initialize(port: number | string): Promise<HttpServer> {\r\n this._configureMiddleware();\r\n this._configureHeaders();\r\n this._configureRoutes();\r\n\r\n this._app.set(\"port\", port);\r\n return new Promise<HttpServer>((resolve) => {\r\n const server: HttpServer = this._app.listen(this._app.get(\"port\"), () => resolve(server));\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport class WebEditServer extends IModelJsExpressServer {\r\n protected override _configureRoutes() {\r\n (this._app as any).ws(\"/ipc\", (ws: any, _req: any) => LocalhostIpcHost.connect(ws));\r\n super._configureRoutes();\r\n }\r\n\r\n constructor(protocol: WebAppRpcProtocol, config = IModelJsExpressServer.defaults) {\r\n super(protocol, config);\r\n enableWs(this._app);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExpressServer.js","sourceRoot":"","sources":["../../src/ExpressServer.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAAmC;AACnC,uCAAuC;AAEvC,oDAAuG;AAC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AC,CAAC,CAAC;QAC5F,CAAC,CAAC,CAAC;IACL,CAAC;;AAxDD,6CAA6C;AACtB,8BAAQ,GAAgC;IAC7D,WAAW,EAAE,KAAK;CACnB,AAF8B,CAE7B;AAJS,sDAAqB;AA4DlC;;GAEG;AACH,MAAa,aAAc,SAAQ,qBAAqB;IACnC,gBAAgB;QAChC,IAAI,CAAC,IAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAO,EAAE,IAAS,EAAE,EAAE,CAAC,+BAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QACpF,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAED,YAAY,QAA2B,EAAE,MAAM,GAAG,qBAAqB,CAAC,QAAQ;QAC9E,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF;AAVD,sCAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport * as express from \"express\";\r\nimport * as enableWs from \"express-ws\";\r\nimport { Server as HttpServer } from \"http\";\r\nimport { BentleyCloudRpcConfiguration, RpcConfiguration, WebAppRpcProtocol } from \"@itwin/core-common\";\r\nimport { LocalhostIpcHost } from \"@itwin/core-backend\";\r\n\r\n/**\r\n * Options for configuring IModelJsExpressServer.\r\n * @public\r\n */\r\nexport interface IModelJsExpressServerConfig {\r\n uploadLimit: string;\r\n}\r\n\r\n/**\r\n * An express web server with some reasonable defaults for web applications built with @bentley/webpack-tools.\r\n * @note This server is not designed to be a hardened, secure endpoint on the public internet.\r\n * It is intended to participate in a private HTTP exchange with a public-facing routing and provisioning infrastructure\r\n * that should be supplied by the application's deployment environment.\r\n * @public\r\n */\r\nexport class IModelJsExpressServer {\r\n /** The default configuration for servers. */\r\n public static readonly defaults: IModelJsExpressServerConfig = {\r\n uploadLimit: \"5mb\",\r\n };\r\n\r\n private _protocol: WebAppRpcProtocol;\r\n private _config: IModelJsExpressServerConfig;\r\n protected _app: import(\"express\").Application = express();\r\n\r\n /** @alpha */\r\n public get rpcConfiguration(): RpcConfiguration { return this._protocol.configuration; }\r\n\r\n constructor(protocol: WebAppRpcProtocol, config = IModelJsExpressServer.defaults) {\r\n this._protocol = protocol;\r\n this._config = config;\r\n }\r\n\r\n protected _configureMiddleware() {\r\n this._app.use(express.text({ limit: this._config.uploadLimit }));\r\n this._app.use(express.raw({ limit: this._config.uploadLimit }));\r\n }\r\n\r\n protected _configureHeaders() {\r\n // enable CORS for all apis\r\n this._app.all(\"/**\", (_req, res, next) => {\r\n res.header(\"Access-Control-Allow-Origin\", BentleyCloudRpcConfiguration.accessControl.allowOrigin);\r\n res.header(\"Access-Control-Allow-Methods\", BentleyCloudRpcConfiguration.accessControl.allowMethods);\r\n res.header(\"Access-Control-Allow-Headers\", BentleyCloudRpcConfiguration.accessControl.allowHeaders);\r\n next();\r\n });\r\n }\r\n\r\n protected _configureRoutes() {\r\n this._app.get(\"/v3/swagger.json\", (req, res) => this._protocol.handleOpenApiDescriptionRequest(req, res));\r\n this._app.post(\"*\", async (req, res) => this._protocol.handleOperationPostRequest(req, res));\r\n this._app.get(/\\/imodel\\//, async (req, res) => this._protocol.handleOperationGetRequest(req, res));\r\n this._app.get(\"/ping\", async (_req, res) => res.status(200).send(\"Success\"));\r\n // for all HTTP requests, identify the server.\r\n this._app.use(\"*\", (_req, resp) => {\r\n resp.send(\"<h1>IModelJs RPC Server</h1>\");\r\n });\r\n }\r\n\r\n /**\r\n * Configure the express application with necessary headers, routes, and middleware, then starts listening on the given port.\r\n * @param port The port to listen on\r\n */\r\n public async initialize(port: number | string): Promise<HttpServer> {\r\n this._configureMiddleware();\r\n this._configureHeaders();\r\n this._configureRoutes();\r\n\r\n this._app.set(\"port\", port);\r\n return new Promise<HttpServer>((resolve) => {\r\n const server: HttpServer = this._app.listen(this._app.get(\"port\"), () => resolve(server));\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport class WebEditServer extends IModelJsExpressServer {\r\n protected override _configureRoutes() {\r\n (this._app as any).ws(\"/ipc\", (ws: any, _req: any) => LocalhostIpcHost.connect(ws));\r\n super._configureRoutes();\r\n }\r\n\r\n constructor(protocol: WebAppRpcProtocol, config = IModelJsExpressServer.defaults) {\r\n super(protocol, config);\r\n enableWs(this._app);\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@itwin/express-server",
3
- "version": "4.0.0-dev.8",
3
+ "version": "4.0.0-dev.80",
4
4
  "description": "iTwin.js express utilities",
5
5
  "main": "lib/cjs/ExpressServer.js",
6
6
  "typings": "lib/cjs/ExpressServer",
7
7
  "license": "MIT",
8
8
  "engines": {
9
- "node": ">=16.13.0 < 19.0"
9
+ "node": "^18.0.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/iTwin/itwinjs-core/tree/master/core/express-server"
13
+ "url": "https://github.com/iTwin/itwinjs-core.git",
14
+ "directory": "core/express-server"
14
15
  },
15
16
  "keywords": [
16
17
  "Bentley",
@@ -24,29 +25,29 @@
24
25
  "url": "http://www.bentley.com"
25
26
  },
26
27
  "devDependencies": {
27
- "@itwin/build-tools": "4.0.0-dev.8",
28
- "@itwin/core-common": "4.0.0-dev.8",
29
- "@itwin/core-backend": "4.0.0-dev.8",
30
- "@itwin/eslint-plugin": "4.0.0-dev.8",
28
+ "@itwin/build-tools": "4.0.0-dev.80",
29
+ "@itwin/core-common": "4.0.0-dev.80",
30
+ "@itwin/core-backend": "4.0.0-dev.80",
31
+ "@itwin/eslint-plugin": "^4.0.0-dev.33",
31
32
  "@types/body-parser": "^1.17.0",
32
33
  "@types/chai": "4.3.1",
33
34
  "@types/express": "^4.16.1",
34
35
  "@types/mocha": "^8.2.2",
35
- "@types/node": "18.11.5",
36
+ "@types/node": "^18.11.5",
36
37
  "@types/sinon": "^9.0.0",
37
38
  "@types/supertest": "^2.0.4",
38
39
  "@types/express-ws": "^3.0.1",
39
40
  "chai": "^4.1.2",
40
- "eslint": "^7.11.0",
41
+ "eslint": "^8.36.0",
41
42
  "mocha": "^10.0.0",
42
43
  "nyc": "^15.1.0",
43
44
  "rimraf": "^3.0.2",
44
45
  "sinon": "^9.0.2",
45
46
  "supertest": "^3.0.0",
46
- "typescript": "~4.4.0"
47
+ "typescript": "~5.0.2"
47
48
  },
48
49
  "peerDependencies": {
49
- "@itwin/core-backend": "4.0.0-dev.8"
50
+ "@itwin/core-backend": "4.0.0-dev.80"
50
51
  },
51
52
  "dependencies": {
52
53
  "express": "^4.16.3",
@@ -63,7 +64,6 @@
63
64
  },
64
65
  "scripts": {
65
66
  "build": "npm run -s build:cjs",
66
- "build:ci": "npm run -s build",
67
67
  "build:cjs": "tsc 1>&2 --outDir lib/cjs",
68
68
  "clean": "rimraf lib .rush/temp/package-deps*.json",
69
69
  "docs": "betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/express-server/file.json --tsIndexFile=./ExpressServer.ts --onlyJson",