@lwrjs/server 0.6.0 → 0.6.4
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.
|
@@ -34,15 +34,24 @@ var import_abstract_internal_app_server = __toModule(require("../common/abstract
|
|
|
34
34
|
var import_express_request = __toModule(require("./express-request.cjs"));
|
|
35
35
|
var import_express_response = __toModule(require("./express-response.cjs"));
|
|
36
36
|
var ExpressInternalServer = class extends import_abstract_internal_app_server.default {
|
|
37
|
-
constructor() {
|
|
37
|
+
constructor(options) {
|
|
38
38
|
super();
|
|
39
39
|
this.expressApp = (0, import_express.default)();
|
|
40
|
+
if (options.basePath) {
|
|
41
|
+
this.basePath = options.basePath;
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
getImpl() {
|
|
42
45
|
return this.expressApp;
|
|
43
46
|
}
|
|
44
47
|
createHttpServer() {
|
|
45
|
-
|
|
48
|
+
if (this.basePath) {
|
|
49
|
+
const server = (0, import_express.default)();
|
|
50
|
+
server.use(this.basePath, this.expressApp);
|
|
51
|
+
this.httpServer = import_http.default.createServer(server);
|
|
52
|
+
} else {
|
|
53
|
+
this.httpServer = import_http.default.createServer(this.expressApp);
|
|
54
|
+
}
|
|
46
55
|
return this.httpServer;
|
|
47
56
|
}
|
|
48
57
|
createHttp2Server() {
|
package/build/cjs/index.cjs
CHANGED
|
@@ -35,9 +35,9 @@ var import_express_response = __toModule(require("./express/express-response.cjs
|
|
|
35
35
|
var import_koa_server = __toModule(require("./koa/koa-server.cjs"));
|
|
36
36
|
var import_fs_server = __toModule(require("./fs/fs-server.cjs"));
|
|
37
37
|
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
38
|
-
function createInternalServer(serverType = "express") {
|
|
38
|
+
function createInternalServer(serverType = "express", options = {}) {
|
|
39
39
|
if (serverType === "express") {
|
|
40
|
-
const expressAppServer = new import_express_server.default();
|
|
40
|
+
const expressAppServer = new import_express_server.default(options);
|
|
41
41
|
return expressAppServer;
|
|
42
42
|
}
|
|
43
43
|
if (serverType === "koa") {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Application as ExpressApp } from 'express';
|
|
3
3
|
import http from 'http';
|
|
4
4
|
import http2 from 'http2';
|
|
5
|
-
import { InternalAppServer } from '@lwrjs/types';
|
|
5
|
+
import { InternalAppServer, InternalAppServerOptions } from '@lwrjs/types';
|
|
6
6
|
import AbstractInternalAppServer from '../common/abstract-internal-app-server.js';
|
|
7
7
|
/**
|
|
8
8
|
* Express Server Implementation (https://expressjs.com/)
|
|
@@ -11,7 +11,8 @@ export default class ExpressInternalServer extends AbstractInternalAppServer imp
|
|
|
11
11
|
private expressApp;
|
|
12
12
|
private httpServer?;
|
|
13
13
|
private http2Server?;
|
|
14
|
-
|
|
14
|
+
private basePath?;
|
|
15
|
+
constructor(options: InternalAppServerOptions);
|
|
15
16
|
getImpl(): ExpressApp;
|
|
16
17
|
createHttpServer(): http.Server;
|
|
17
18
|
createHttp2Server(): http2.Http2Server;
|
|
@@ -9,15 +9,25 @@ import ExpressResponse from './express-response.js';
|
|
|
9
9
|
* Express Server Implementation (https://expressjs.com/)
|
|
10
10
|
*/
|
|
11
11
|
export default class ExpressInternalServer extends AbstractInternalAppServer {
|
|
12
|
-
constructor() {
|
|
12
|
+
constructor(options) {
|
|
13
13
|
super();
|
|
14
14
|
this.expressApp = express();
|
|
15
|
+
if (options.basePath) {
|
|
16
|
+
this.basePath = options.basePath;
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
getImpl() {
|
|
17
20
|
return this.expressApp;
|
|
18
21
|
}
|
|
19
22
|
createHttpServer() {
|
|
20
|
-
|
|
23
|
+
if (this.basePath) {
|
|
24
|
+
const server = express();
|
|
25
|
+
server.use(this.basePath, this.expressApp);
|
|
26
|
+
this.httpServer = http.createServer(server);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.httpServer = http.createServer(this.expressApp);
|
|
30
|
+
}
|
|
21
31
|
return this.httpServer;
|
|
22
32
|
}
|
|
23
33
|
createHttp2Server() {
|
package/build/es/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { LwrFsKoa } from './fs/fs-server.js';
|
|
2
2
|
import { InternalAppServer, MiddlewareRequest, MiddlewareResponse, ServerTypes } from '@lwrjs/types';
|
|
3
3
|
import { Request, Response } from 'express';
|
|
4
|
-
declare
|
|
4
|
+
declare type ServerOptions = {
|
|
5
|
+
basePath?: string;
|
|
6
|
+
};
|
|
7
|
+
declare function createInternalServer<T extends ServerTypes>(serverType?: string, options?: ServerOptions): InternalAppServer<T>;
|
|
5
8
|
declare function mockMiddlewareRequest(req: Request): MiddlewareRequest;
|
|
6
9
|
declare function mockMiddlewareResponse(res: Response): MiddlewareResponse;
|
|
7
10
|
export { createInternalServer, mockMiddlewareRequest, mockMiddlewareResponse, LwrFsKoa };
|
package/build/es/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import ExpressResponse from './express/express-response.js';
|
|
|
4
4
|
import KoaInternalServer from './koa/koa-server.js';
|
|
5
5
|
import { FsInternalServer, LwrFsKoa } from './fs/fs-server.js';
|
|
6
6
|
import { createSingleDiagnosticError, descriptions, LwrConfigValidationError } from '@lwrjs/diagnostics';
|
|
7
|
-
function createInternalServer(serverType = 'express') {
|
|
7
|
+
function createInternalServer(serverType = 'express', options = {}) {
|
|
8
8
|
if (serverType === 'express') {
|
|
9
|
-
const expressAppServer = new ExpressInternalServer();
|
|
9
|
+
const expressAppServer = new ExpressInternalServer(options);
|
|
10
10
|
return expressAppServer;
|
|
11
11
|
}
|
|
12
12
|
if (serverType === 'koa') {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.6.
|
|
7
|
+
"version": "0.6.4",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"build/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@lwrjs/types": "0.6.
|
|
33
|
+
"@lwrjs/types": "0.6.4",
|
|
34
34
|
"@types/koa-compress": "^4.0.1",
|
|
35
35
|
"@types/koa__router": "^8.0.4",
|
|
36
36
|
"@types/spdy": "^3.4.4",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@koa/router": "^10.0.0",
|
|
41
|
-
"@lwrjs/shared-utils": "0.6.
|
|
41
|
+
"@lwrjs/shared-utils": "0.6.4",
|
|
42
42
|
"@types/express": "^4.17.11",
|
|
43
43
|
"@types/koa": "^2.11.7",
|
|
44
44
|
"express": "^4.17.1",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=14.15.4 <17"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "80b73fe4558dc3db0afcdbe80eb17f5a1464e34e"
|
|
55
55
|
}
|