@haibun/web-server-express 1.13.6 → 1.13.13
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/build/defs.d.ts +4 -5
- package/build/defs.js +2 -5
- package/build/defs.js.map +1 -1
- package/build/server-express.d.ts +3 -4
- package/build/server-express.js +19 -23
- package/build/server-express.js.map +1 -1
- package/build/web-server-stepper-route.test.d.ts +0 -1
- package/build/web-server-stepper-route.test.js +23 -31
- package/build/web-server-stepper-route.test.js.map +1 -1
- package/build/web-server-stepper.d.ts +14 -15
- package/build/web-server-stepper.js +93 -97
- package/build/web-server-stepper.js.map +1 -1
- package/build/web-server-stepper.test.d.ts +0 -1
- package/build/web-server-stepper.test.js +7 -12
- package/build/web-server-stepper.test.js.map +1 -1
- package/package.json +9 -18
- package/build/defs.d.ts.map +0 -1
- package/build/server-express.d.ts.map +0 -1
- package/build/web-server-stepper-route.test.d.ts.map +0 -1
- package/build/web-server-stepper.d.ts.map +0 -1
- package/build/web-server-stepper.test.d.ts.map +0 -1
package/build/defs.d.ts
CHANGED
|
@@ -8,8 +8,7 @@ export interface IWebServer {
|
|
|
8
8
|
close(): Promise<void>;
|
|
9
9
|
addRoute(type: TRouteTypes, path: string, route: TRequestHandler): void;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
//# sourceMappingURL=defs.d.ts.map
|
|
11
|
+
export type TRouteTypes = 'get' | 'post';
|
|
12
|
+
export type IRequest = typeof express.request;
|
|
13
|
+
export type IResponse = typeof express.response;
|
|
14
|
+
export type TRequestHandler = (req: IRequest, res: IResponse) => void;
|
package/build/defs.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CHECK_LISTENER = exports.WEBSERVER = void 0;
|
|
4
|
-
exports.WEBSERVER = 'webserver';
|
|
5
|
-
exports.CHECK_LISTENER = 'CHECK_LISTENER';
|
|
1
|
+
export const WEBSERVER = 'webserver';
|
|
2
|
+
export const CHECK_LISTENER = 'CHECK_LISTENER';
|
|
6
3
|
//# sourceMappingURL=defs.js.map
|
package/build/defs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.js","sourceRoot":"","sources":["../src/defs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defs.js","sourceRoot":"","sources":["../src/defs.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import { RequestHandler } from 'express';
|
|
4
|
-
import { IWebServer, TRouteTypes } from './defs';
|
|
5
|
-
import { ILogger } from '@haibun/core/build/lib/interfaces/logger';
|
|
4
|
+
import { IWebServer, TRouteTypes } from './defs.js';
|
|
5
|
+
import { ILogger } from '@haibun/core/build/lib/interfaces/logger.js';
|
|
6
6
|
export declare const DEFAULT_PORT = 8123;
|
|
7
7
|
export declare function shutdown(): Promise<void>;
|
|
8
8
|
export declare class ServerExpress implements IWebServer {
|
|
@@ -25,4 +25,3 @@ export declare class ServerExpress implements IWebServer {
|
|
|
25
25
|
checkMountBadOrMounted(loc: string, what: string): boolean;
|
|
26
26
|
close(): Promise<void>;
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=server-express.d.ts.map
|
package/build/server-express.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.ServerExpress = exports.shutdown = exports.DEFAULT_PORT = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const express_1 = __importDefault(require("express"));
|
|
9
|
-
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
10
|
-
exports.DEFAULT_PORT = 8123;
|
|
11
|
-
async function shutdown() {
|
|
1
|
+
import { statSync, existsSync } from 'fs';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import cookieParser from 'cookie-parser';
|
|
4
|
+
export const DEFAULT_PORT = 8123;
|
|
5
|
+
export async function shutdown() {
|
|
12
6
|
await fetch('//localhost:8123/shutdown', { method: 'POST' });
|
|
13
7
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
export class ServerExpress {
|
|
9
|
+
logger;
|
|
10
|
+
static listening = false;
|
|
11
|
+
listener;
|
|
12
|
+
app = express();
|
|
13
|
+
static mounted = {};
|
|
14
|
+
base;
|
|
15
|
+
port;
|
|
16
|
+
constructor(logger, base, port = DEFAULT_PORT) {
|
|
18
17
|
this.logger = logger;
|
|
19
18
|
this.base = base;
|
|
20
19
|
this.port = port;
|
|
21
|
-
this.app.use((
|
|
22
|
-
this.app.use(
|
|
20
|
+
this.app.use(cookieParser());
|
|
21
|
+
this.app.use(express.json({ limit: '50mb' }));
|
|
23
22
|
}
|
|
24
23
|
async listen() {
|
|
25
24
|
if (!ServerExpress.listening) {
|
|
@@ -81,15 +80,15 @@ class ServerExpress {
|
|
|
81
80
|
catch (e) {
|
|
82
81
|
return e.message;
|
|
83
82
|
}
|
|
84
|
-
if (!
|
|
83
|
+
if (!existsSync(folder)) {
|
|
85
84
|
throw Error(`"${folder}" doesn't exist`);
|
|
86
85
|
}
|
|
87
|
-
const stat =
|
|
86
|
+
const stat = statSync(folder);
|
|
88
87
|
if (!stat.isDirectory()) {
|
|
89
88
|
throw Error(`"${folder}" is not a directory`);
|
|
90
89
|
}
|
|
91
90
|
this.logger.info(`serving files from ${folder} at ${mountAt}`);
|
|
92
|
-
await this.app.use(mountAt,
|
|
91
|
+
await this.app.use(mountAt, express.static(folder));
|
|
93
92
|
await this.addMounted(mountAt, folder);
|
|
94
93
|
return;
|
|
95
94
|
}
|
|
@@ -109,7 +108,4 @@ class ServerExpress {
|
|
|
109
108
|
await this.listener?.close();
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
|
-
exports.ServerExpress = ServerExpress;
|
|
113
|
-
ServerExpress.listening = false;
|
|
114
|
-
ServerExpress.mounted = {};
|
|
115
111
|
//# sourceMappingURL=server-express.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-express.js","sourceRoot":"","sources":["../src/server-express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-express.js","sourceRoot":"","sources":["../src/server-express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAG1C,OAAO,OAA2B,MAAM,SAAS,CAAC;AAClD,OAAO,YAAY,MAAM,eAAe,CAAC;AAKzC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,KAAK,CAAC,2BAA2B,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,OAAO,aAAa;IACxB,MAAM,CAAU;IAChB,MAAM,CAAC,SAAS,GAAY,KAAK,CAAC;IAClC,QAAQ,CAAe;IACvB,GAAG,GAAG,OAAO,EAAE,CAAC;IAChB,MAAM,CAAC,OAAO,GAAgC,EAAE,CAAC;IACjD,IAAI,CAAS;IACb,IAAI,CAAS;IACb,YAAY,MAAe,EAAE,IAAY,EAAE,OAAe,YAAY;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO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ault(require("./web-server-stepper"));
|
|
11
|
-
const defs_3 = require("@haibun/core/build/lib/defs");
|
|
12
|
-
const lib_1 = require("@haibun/core/src/lib/test/lib");
|
|
13
|
-
const web_server_stepper_2 = __importDefault(require("./web-server-stepper"));
|
|
1
|
+
import WebHttp from '@haibun/web-http/build/web-http.js';
|
|
2
|
+
import { actionOK, getFromRuntime, getStepperOptionName } from '@haibun/core/build/lib/util/index.js';
|
|
3
|
+
import { DEFAULT_DEST } from '@haibun/core/build/lib/defs.js';
|
|
4
|
+
import { WEBSERVER } from './defs.js';
|
|
5
|
+
import Server from './web-server-stepper.js';
|
|
6
|
+
import { AStepper } from '@haibun/core/build/lib/defs.js';
|
|
7
|
+
import { testWithDefaults } from '@haibun/core/build/lib/test/lib.js';
|
|
8
|
+
import WebServerStepper from './web-server-stepper.js';
|
|
14
9
|
describe('route mount', () => {
|
|
15
10
|
it.skip('mounts a route', async () => {
|
|
16
|
-
const TestRoute = class TestRoute extends
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
await webserver.addRoute('get', loc, route);
|
|
26
|
-
return (0, util_1.actionOK)();
|
|
27
|
-
},
|
|
11
|
+
const TestRoute = class TestRoute extends AStepper {
|
|
12
|
+
steps = {
|
|
13
|
+
addRoute: {
|
|
14
|
+
gwta: 'serve test route to {loc}',
|
|
15
|
+
action: async ({ loc }) => {
|
|
16
|
+
const route = (req, res) => res.status(200).send('ok');
|
|
17
|
+
const webserver = await getFromRuntime(this.getWorld().runtime, WEBSERVER);
|
|
18
|
+
await webserver.addRoute('get', loc, route);
|
|
19
|
+
return actionOK();
|
|
28
20
|
},
|
|
29
|
-
}
|
|
30
|
-
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
31
23
|
};
|
|
32
|
-
const wss = new
|
|
24
|
+
const wss = new WebServerStepper();
|
|
33
25
|
const feature = { path: '/features/test.feature', content: `serve test route to /test\nwebserver is listening\nfetch from http://localhost:8124/test is "ok"` };
|
|
34
|
-
const result = await
|
|
35
|
-
options: { DEST:
|
|
26
|
+
const result = await testWithDefaults([feature], [Server, TestRoute, WebHttp], {
|
|
27
|
+
options: { DEST: DEFAULT_DEST, },
|
|
36
28
|
extraOptions: {
|
|
37
|
-
[
|
|
29
|
+
[getStepperOptionName(wss, 'PORT')]: '8124',
|
|
38
30
|
},
|
|
39
31
|
});
|
|
40
32
|
expect(result.ok).toBe(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper-route.test.js","sourceRoot":"","sources":["../src/web-server-stepper-route.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-server-stepper-route.test.js","sourceRoot":"","sources":["../src/web-server-stepper-route.test.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,oCAAoC,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAmC,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvE,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAU,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AAEvD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,SAAS,GAAG,MAAM,SAAU,SAAQ,QAAQ;YAChD,KAAK,GAAG;gBACN,QAAQ,EAAE;oBACR,IAAI,EAAE,2BAA2B;oBACjC,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAU,EAAE,EAAE;wBAChC,MAAM,KAAK,GAAG,CAAC,GAAa,EAAE,GAAc,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC5E,MAAM,SAAS,GAAe,MAAM,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;wBACvF,MAAM,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;wBAC5C,OAAO,QAAQ,EAAE,CAAC;oBACpB,CAAC;iBACF;aACF,CAAC;SACH,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,kGAAkG,EAAE,CAAC;QAChK,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE;YAC7E,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,GAAG;YAChC,YAAY,EAAE;gBACZ,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM;aAC5C;SACF,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TWorld, TNamed, TOptions, AStepper, TVStep } from '@haibun/core/build/lib/defs';
|
|
2
|
-
import { WorkspaceContext } from '@haibun/core/build/lib/contexts';
|
|
3
|
-
import { IWebServer } from './defs';
|
|
4
|
-
import { ServerExpress } from './server-express';
|
|
1
|
+
import { TWorld, TNamed, TOptions, AStepper, TVStep } from '@haibun/core/build/lib/defs.js';
|
|
2
|
+
import { WorkspaceContext } from '@haibun/core/build/lib/contexts.js';
|
|
3
|
+
import { IWebServer } from './defs.js';
|
|
4
|
+
import { ServerExpress } from './server-express.js';
|
|
5
5
|
declare const WebServerStepper: {
|
|
6
6
|
new (): {
|
|
7
7
|
webserver: ServerExpress | undefined;
|
|
@@ -22,42 +22,41 @@ declare const WebServerStepper: {
|
|
|
22
22
|
steps: {
|
|
23
23
|
thisURI: {
|
|
24
24
|
gwta: string;
|
|
25
|
-
action: ({ where }: TNamed, vstep: TVStep) => Promise<import("@haibun/core/
|
|
25
|
+
action: ({ where }: TNamed, vstep: TVStep) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
|
|
26
26
|
};
|
|
27
27
|
webpage: {
|
|
28
28
|
gwta: string;
|
|
29
|
-
action: ({ name, location }: TNamed, vsteps: TVStep) => Promise<import("@haibun/core/
|
|
29
|
+
action: ({ name, location }: TNamed, vsteps: TVStep) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
|
|
30
30
|
build: ({ location }: TNamed, { source }: TVStep, workspace: WorkspaceContext) => Promise<{
|
|
31
31
|
finalize: (workspace: WorkspaceContext) => void;
|
|
32
32
|
ok: true;
|
|
33
|
-
topics?: import("@haibun/core/
|
|
33
|
+
topics?: import("@haibun/core/build/lib/defs.js").TActionResultTopics;
|
|
34
34
|
}>;
|
|
35
35
|
};
|
|
36
36
|
isListening: {
|
|
37
37
|
gwta: string;
|
|
38
|
-
action: () => Promise<import("@haibun/core/
|
|
38
|
+
action: () => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
|
|
39
39
|
};
|
|
40
40
|
showMounts: {
|
|
41
41
|
gwta: string;
|
|
42
|
-
action: () => Promise<import("@haibun/core/
|
|
42
|
+
action: () => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
|
|
43
43
|
};
|
|
44
44
|
serveFiles: {
|
|
45
45
|
gwta: string;
|
|
46
|
-
action: ({ loc }: TNamed) => Promise<import("@haibun/core/
|
|
47
|
-
build: ({ loc }: TNamed) => Promise<import("@haibun/core/
|
|
46
|
+
action: ({ loc }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
47
|
+
build: ({ loc }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult>;
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
finalize: (workspace: WorkspaceContext) => void;
|
|
51
|
-
world?: TWorld
|
|
51
|
+
world?: TWorld;
|
|
52
52
|
endFeature?(): void;
|
|
53
|
-
onFailure?(result: import("@haibun/core/
|
|
53
|
+
onFailure?(result: import("@haibun/core/build/lib/defs.js").TStepResult): void;
|
|
54
54
|
getWorld(): TWorld;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
export default WebServerStepper;
|
|
58
|
-
export
|
|
58
|
+
export type ICheckListener = (options: TOptions, webserver: IWebServer) => void;
|
|
59
59
|
export interface IWebServerStepper {
|
|
60
60
|
webserver: IWebServer;
|
|
61
61
|
close: () => void;
|
|
62
62
|
}
|
|
63
|
-
//# sourceMappingURL=web-server-stepper.d.ts.map
|
|
@@ -1,107 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
parse: (port) => (0, util_1.intOrError)(port)
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
this.steps = {
|
|
20
|
-
thisURI: {
|
|
21
|
-
gwta: `a ${domain_webpage_1.WEB_PAGE} at {where}`,
|
|
22
|
-
action: async ({ where }, vstep) => {
|
|
23
|
-
const page = vstep.source.name;
|
|
24
|
-
const webserver = (0, util_1.getFromRuntime)(this.getWorld().runtime, defs_2.WEBSERVER);
|
|
25
|
-
webserver.addStaticFolder(page);
|
|
26
|
-
console.debug('added page', page);
|
|
27
|
-
return defs_1.OK;
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
/// generator
|
|
31
|
-
webpage: {
|
|
32
|
-
gwta: `A ${domain_webpage_1.WEB_PAGE} {name} hosted at {location}`,
|
|
33
|
-
action: async ({ name, location }, vsteps) => {
|
|
34
|
-
const page = vsteps.source.name;
|
|
35
|
-
const webserver = (0, util_1.getFromRuntime)(this.getWorld().runtime, defs_2.WEBSERVER);
|
|
36
|
-
// TODO mount the page
|
|
37
|
-
return defs_1.OK;
|
|
38
|
-
},
|
|
39
|
-
build: async ({ location }, { source }, workspace) => {
|
|
40
|
-
if (location !== location.replace(/[^a-zA-Z-0-9\.]/g, '')) {
|
|
41
|
-
throw Error(`${domain_webpage_1.WEB_PAGE} location ${location} has millegal characters`);
|
|
42
|
-
}
|
|
43
|
-
const subdir = this.getWorld().shared.get('file_location');
|
|
44
|
-
if (!subdir) {
|
|
45
|
-
throw Error(`must declare a file_location`);
|
|
46
|
-
}
|
|
47
|
-
const folder = `files/${subdir}`;
|
|
48
|
-
workspace.addBuilder(new WebPageBuilder_1.WebPageBuilder(source.name, this.getWorld().logger, location, folder));
|
|
49
|
-
return { ...defs_1.OK, finalize: this.finalize };
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
isListening: {
|
|
53
|
-
gwta: 'webserver is listening',
|
|
54
|
-
action: async () => {
|
|
55
|
-
await this.webserver.listen();
|
|
56
|
-
return defs_1.OK;
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
showMounts: {
|
|
60
|
-
gwta: 'show mounts',
|
|
61
|
-
action: async () => {
|
|
62
|
-
const mounts = server_express_1.ServerExpress.mounted;
|
|
63
|
-
this.getWorld().logger.info(`mounts: ${JSON.stringify(mounts)}`);
|
|
64
|
-
return defs_1.OK;
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
serveFiles: {
|
|
68
|
-
gwta: 'serve files from {loc}',
|
|
69
|
-
action: async ({ loc }) => {
|
|
70
|
-
const ws = await (0, util_1.getFromRuntime)(this.getWorld().runtime, defs_2.WEBSERVER);
|
|
71
|
-
const error = await ws.addStaticFolder(loc);
|
|
72
|
-
this.getWorld().shared.set('file_location', loc);
|
|
73
|
-
return error === undefined ? defs_1.OK : (0, util_1.actionNotOK)(error);
|
|
74
|
-
},
|
|
75
|
-
build: async ({ loc }) => {
|
|
76
|
-
this.getWorld().shared.set('file_location', loc);
|
|
77
|
-
return defs_1.OK;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
this.finalize = (workspace) => {
|
|
82
|
-
if (workspace.get('_finalized')) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
workspace.set('_finalized', true);
|
|
86
|
-
const builder = workspace.getBuilder();
|
|
87
|
-
const shared = builder.finalize();
|
|
88
|
-
const domain = (0, domain_1.getDomain)(domain_webpage_1.WEB_PAGE, this.getWorld()).shared.get(builder.name);
|
|
89
|
-
for (const [name, val] of shared) {
|
|
90
|
-
domain.set(name, val);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
1
|
+
import { OK, AStepper } from '@haibun/core/build/lib/defs.js';
|
|
2
|
+
import { actionNotOK, getFromRuntime, getStepperOption, intOrError } from '@haibun/core/build/lib/util/index.js';
|
|
3
|
+
import { WEBSERVER, } from './defs.js';
|
|
4
|
+
import { ServerExpress, DEFAULT_PORT } from './server-express.js';
|
|
5
|
+
import { WebPageBuilder } from '@haibun/domain-webpage/build/WebPageBuilder.js';
|
|
6
|
+
import { WEB_PAGE } from '@haibun/domain-webpage/build/domain-webpage.js';
|
|
7
|
+
import { getDomain } from '@haibun/core/build/lib/domain.js';
|
|
8
|
+
const WebServerStepper = class WebServerStepper extends AStepper {
|
|
9
|
+
webserver;
|
|
10
|
+
options = {
|
|
11
|
+
PORT: {
|
|
12
|
+
desc: `change web server port from ${DEFAULT_PORT}`,
|
|
13
|
+
parse: (port) => intOrError(port)
|
|
14
|
+
},
|
|
15
|
+
};
|
|
94
16
|
setWorld(world, steppers) {
|
|
95
17
|
super.setWorld(world, steppers);
|
|
96
18
|
// this.world.runtime[CHECK_LISTENER] = WebServerStepper.checkListener;
|
|
97
|
-
const port = parseInt(
|
|
98
|
-
this.webserver = new
|
|
99
|
-
world.runtime[
|
|
19
|
+
const port = parseInt(getStepperOption(this, 'PORT', world.extraOptions)) || DEFAULT_PORT;
|
|
20
|
+
this.webserver = new ServerExpress(world.logger, [process.cwd(), 'files'].join('/'), port);
|
|
21
|
+
world.runtime[WEBSERVER] = this.webserver;
|
|
100
22
|
}
|
|
101
23
|
async close() {
|
|
102
24
|
console.log('closing webserver');
|
|
103
25
|
await this.webserver?.close();
|
|
104
26
|
}
|
|
27
|
+
steps = {
|
|
28
|
+
thisURI: {
|
|
29
|
+
gwta: `a ${WEB_PAGE} at {where}`,
|
|
30
|
+
action: async ({ where }, vstep) => {
|
|
31
|
+
const page = vstep.source.name;
|
|
32
|
+
const webserver = getFromRuntime(this.getWorld().runtime, WEBSERVER);
|
|
33
|
+
webserver.addStaticFolder(page);
|
|
34
|
+
console.debug('added page', page);
|
|
35
|
+
return OK;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
/// generator
|
|
39
|
+
webpage: {
|
|
40
|
+
gwta: `A ${WEB_PAGE} {name} hosted at {location}`,
|
|
41
|
+
action: async ({ name, location }, vsteps) => {
|
|
42
|
+
const page = vsteps.source.name;
|
|
43
|
+
const webserver = getFromRuntime(this.getWorld().runtime, WEBSERVER);
|
|
44
|
+
// TODO mount the page
|
|
45
|
+
return OK;
|
|
46
|
+
},
|
|
47
|
+
build: async ({ location }, { source }, workspace) => {
|
|
48
|
+
if (location !== location.replace(/[^a-zA-Z-0-9\.]/g, '')) {
|
|
49
|
+
throw Error(`${WEB_PAGE} location ${location} has millegal characters`);
|
|
50
|
+
}
|
|
51
|
+
const subdir = this.getWorld().shared.get('file_location');
|
|
52
|
+
if (!subdir) {
|
|
53
|
+
throw Error(`must declare a file_location`);
|
|
54
|
+
}
|
|
55
|
+
const folder = `files/${subdir}`;
|
|
56
|
+
workspace.addBuilder(new WebPageBuilder(source.name, this.getWorld().logger, location, folder));
|
|
57
|
+
return { ...OK, finalize: this.finalize };
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
isListening: {
|
|
61
|
+
gwta: 'webserver is listening',
|
|
62
|
+
action: async () => {
|
|
63
|
+
await this.webserver.listen();
|
|
64
|
+
return OK;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
showMounts: {
|
|
68
|
+
gwta: 'show mounts',
|
|
69
|
+
action: async () => {
|
|
70
|
+
const mounts = ServerExpress.mounted;
|
|
71
|
+
this.getWorld().logger.info(`mounts: ${JSON.stringify(mounts)}`);
|
|
72
|
+
return OK;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
serveFiles: {
|
|
76
|
+
gwta: 'serve files from {loc}',
|
|
77
|
+
action: async ({ loc }) => {
|
|
78
|
+
const ws = await getFromRuntime(this.getWorld().runtime, WEBSERVER);
|
|
79
|
+
const error = await ws.addStaticFolder(loc);
|
|
80
|
+
this.getWorld().shared.set('file_location', loc);
|
|
81
|
+
return error === undefined ? OK : actionNotOK(error);
|
|
82
|
+
},
|
|
83
|
+
build: async ({ loc }) => {
|
|
84
|
+
this.getWorld().shared.set('file_location', loc);
|
|
85
|
+
return OK;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
finalize = (workspace) => {
|
|
90
|
+
if (workspace.get('_finalized')) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
workspace.set('_finalized', true);
|
|
94
|
+
const builder = workspace.getBuilder();
|
|
95
|
+
const shared = builder.finalize();
|
|
96
|
+
const domain = getDomain(WEB_PAGE, this.getWorld()).shared.get(builder.name);
|
|
97
|
+
for (const [name, val] of shared) {
|
|
98
|
+
domain.set(name, val);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
105
101
|
};
|
|
106
|
-
|
|
102
|
+
export default WebServerStepper;
|
|
107
103
|
//# sourceMappingURL=web-server-stepper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper.js","sourceRoot":"","sources":["../src/web-server-stepper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-server-stepper.js","sourceRoot":"","sources":["../src/web-server-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAA4B,QAAQ,EAAuB,MAAM,gCAAgC,CAAC;AAC1H,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEjH,OAAO,EAAc,SAAS,GAAG,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAM,gBAAgB,GAAG,MAAM,gBAAiB,SAAQ,QAAQ;IAC9D,SAAS,CAA4B;IAErC,OAAO,GAAG;QACR,IAAI,EAAE;YACJ,IAAI,EAAE,+BAA+B,YAAY,EAAE;YACnD,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;SAC1C;KACF,CAAC;IAEF,QAAQ,CAAC,KAAa,EAAE,QAAoB;QAC1C,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAChC,uEAAuE;QACvE,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC;QAC1F,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,CA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@@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lib_1 = require("@haibun/core/build/lib/test/lib");
|
|
7
|
-
const web_http_1 = __importDefault(require("@haibun/web-http/build/web-http"));
|
|
8
|
-
const web_server_stepper_1 = __importDefault(require("./web-server-stepper"));
|
|
1
|
+
import { testWithDefaults } from '@haibun/core/build/lib/test/lib.js';
|
|
2
|
+
import WebHttp from '@haibun/web-http/build/web-http.js';
|
|
3
|
+
import server from './web-server-stepper.js';
|
|
9
4
|
describe.skip('static mount', () => {
|
|
10
5
|
it('serves files', async () => {
|
|
11
6
|
const feature = { path: '/features/test.feature', content: `serve files from test\nfetch from http://localhost:8123/testfile is "content"` };
|
|
12
|
-
const result = await
|
|
7
|
+
const result = await testWithDefaults([feature], [server, WebHttp]);
|
|
13
8
|
expect(result.ok).toBe(true);
|
|
14
9
|
});
|
|
15
10
|
it('restricts characters used in static mount folder name', async () => {
|
|
16
11
|
const feature = { path: '/features/test.feature', content: `serve files from l*(*$\n` };
|
|
17
|
-
const result = await
|
|
12
|
+
const result = await testWithDefaults([feature], [server]);
|
|
18
13
|
expect(result.ok).toBe(false);
|
|
19
14
|
});
|
|
20
15
|
it("doesn't re-mount same static mount", async () => {
|
|
21
16
|
const feature = { path: '/features/test.feature', content: `serve files from test\nserve files from test\n` };
|
|
22
|
-
const result = await
|
|
17
|
+
const result = await testWithDefaults([feature], [server]);
|
|
23
18
|
expect(result.ok).toBe(true);
|
|
24
19
|
});
|
|
25
20
|
it("doesn't permit different static mount", async () => {
|
|
26
21
|
const feature = { path: '/features/test.feature', content: `serve files from test\nserve files from fails\n` };
|
|
27
|
-
const result = await
|
|
22
|
+
const result = await testWithDefaults([feature], [server]);
|
|
28
23
|
expect(result.ok).toBe(false);
|
|
29
24
|
});
|
|
30
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper.test.js","sourceRoot":"","sources":["../src/web-server-stepper.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-server-stepper.test.js","sourceRoot":"","sources":["../src/web-server-stepper.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,OAAO,MAAM,oCAAoC,CAAC;AAEzD,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAE7C,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QAC5B,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,+EAA+E,EAAE,CAAC;QAC7I,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAEpE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAA;QACvF,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAE3D,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,gDAAgD,EAAE,CAAA;QAC7G,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAE3D,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAA;QAC9G,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAE3D,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haibun/web-server-express",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.13.13",
|
|
4
5
|
"description": "",
|
|
5
6
|
"main": "build/web-server-stepper.js",
|
|
6
7
|
"files": [
|
|
@@ -8,32 +9,22 @@
|
|
|
8
9
|
],
|
|
9
10
|
"scripts": {
|
|
10
11
|
"prepublishOnly": "tsc -b .",
|
|
11
|
-
"
|
|
12
|
-
"test
|
|
12
|
+
"build": "tsc -b .",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"test-watch": "jest --watch"
|
|
13
15
|
},
|
|
14
16
|
"keywords": [],
|
|
15
17
|
"author": "",
|
|
16
18
|
"license": "ISC",
|
|
17
19
|
"dependencies": {
|
|
18
|
-
"@
|
|
20
|
+
"@haibun/core": "1.13.13",
|
|
21
|
+
"@haibun/domain-webpage": "1.13.13",
|
|
19
22
|
"cookie-parser": "^1.4.5",
|
|
20
23
|
"express": "^4.17.1"
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
26
|
+
"@haibun/web-http": "1.13.13",
|
|
23
27
|
"@types/express": "^4.17.15",
|
|
24
|
-
"@types/
|
|
25
|
-
"@types/node": "^18.11.14",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^4.13.0",
|
|
27
|
-
"@typescript-eslint/parser": "^4.13.0",
|
|
28
|
-
"eslint": "^7.2.0",
|
|
29
|
-
"eslint-config-airbnb-typescript": "^12.0.0",
|
|
30
|
-
"eslint-config-prettier": "^8.3.0",
|
|
31
|
-
"eslint-plugin-import": "^2.22.1",
|
|
32
|
-
"eslint-plugin-prefer-arrow": "^1.2.2",
|
|
33
|
-
"eslint-plugin-prettier": "^3.3.1",
|
|
34
|
-
"jest": "^29.3.1",
|
|
35
|
-
"prettier": "^2.3.1",
|
|
36
|
-
"ts-node": "^10.0.0",
|
|
37
|
-
"tslint": "^6.1.3"
|
|
28
|
+
"@types/cookie-parser": "^1.4.2"
|
|
38
29
|
}
|
|
39
30
|
}
|
package/build/defs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../src/defs.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7D,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACpF,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,IA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QrC,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,MAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS3F,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIxF,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAwB3F,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAWpD,KAAK;CAIZ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper-route.test.d.ts","sourceRoot":"","sources":["../src/web-server-stepper-route.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper.d.ts","sourceRoot":"","sources":["../src/web-server-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,6BAA6B,CAAC;AAEvH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAc,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAK/D,QAAA,MAAM,gBAAgB;;mBACT,aAAa,GAAG,SAAS;;;;8BAKlB,MAAM;;;;;;;;;wBAIR,MAAM,YAAY,QAAQ,EAAE;;;;;oCAiBd,MAAM,SAAS,MAAM;;;;6CAaZ,MAAM,UAAU,MAAM;sCAO7B,MAAM,cAAc,MAAM,aAAa,gBAAgB;0CA2ChE,gBAAgB;;;;;;;;;;;;;;;kCAbX,MAAM;iCAOP,MAAM;;;8BAMV,gBAAgB;;;;;;CAcxC,CAAC;AACF,eAAe,gBAAgB,CAAC;AAEhC,oBAAY,cAAc,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,KAAK,IAAI,CAAC;AAChF,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,UAAU,CAAC;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper.test.d.ts","sourceRoot":"","sources":["../src/web-server-stepper.test.ts"],"names":[],"mappings":""}
|