@haibun/web-server-express 1.9.0 → 1.9.3
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { TWorld, TNamed, TOptions, AStepper } from '@haibun/core/build/lib/defs';
|
|
1
|
+
import { TWorld, TNamed, TOptions, AStepper, TVStep } from '@haibun/core/build/lib/defs';
|
|
2
|
+
import { WorkspaceContext } from '@haibun/core/src/lib/contexts';
|
|
2
3
|
import { IWebServer } from './defs';
|
|
3
4
|
import { ServerExpress } from './server-express';
|
|
4
5
|
declare const WebServerStepper: {
|
|
@@ -19,6 +20,19 @@ declare const WebServerStepper: {
|
|
|
19
20
|
setWorld(world: TWorld, steppers: AStepper[]): void;
|
|
20
21
|
close(): Promise<void>;
|
|
21
22
|
steps: {
|
|
23
|
+
thisURI: {
|
|
24
|
+
gwta: string;
|
|
25
|
+
action: ({ where }: TNamed, vstep: TVStep) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
26
|
+
};
|
|
27
|
+
webpage: {
|
|
28
|
+
gwta: string;
|
|
29
|
+
action: ({ name, location }: TNamed, vsteps: TVStep) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
30
|
+
build: ({ location }: TNamed, { source }: TVStep, workspace: WorkspaceContext) => Promise<{
|
|
31
|
+
finalize: (workspace: WorkspaceContext) => void;
|
|
32
|
+
ok: true;
|
|
33
|
+
topics?: import("@haibun/core/build/lib/defs").TActionResultTopics | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
22
36
|
isListening: {
|
|
23
37
|
gwta: string;
|
|
24
38
|
action: () => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
@@ -33,6 +47,7 @@ declare const WebServerStepper: {
|
|
|
33
47
|
build: ({ loc }: TNamed) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
34
48
|
};
|
|
35
49
|
};
|
|
50
|
+
finalize: (workspace: WorkspaceContext) => void;
|
|
36
51
|
world?: TWorld | undefined;
|
|
37
52
|
endFeature?(): void;
|
|
38
53
|
onFailure?(result: import("@haibun/core/build/lib/defs").TStepResult): void;
|
|
@@ -1 +1 @@
|
|
|
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,6BAA6B,CAAC;
|
|
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,+BAA+B,CAAC;AACjE,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;;;;;oCAed,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"}
|
|
@@ -4,6 +4,9 @@ const defs_1 = require("@haibun/core/build/lib/defs");
|
|
|
4
4
|
const util_1 = require("@haibun/core/build/lib/util");
|
|
5
5
|
const defs_2 = require("./defs");
|
|
6
6
|
const server_express_1 = require("./server-express");
|
|
7
|
+
const WebPageBuilder_1 = require("@haibun/domain-webpage/build/WebPageBuilder");
|
|
8
|
+
const domain_webpage_1 = require("@haibun/domain-webpage/build/domain-webpage");
|
|
9
|
+
const domain_1 = require("@haibun/core/build/lib/domain");
|
|
7
10
|
const WebServerStepper = class WebServerStepper extends defs_1.AStepper {
|
|
8
11
|
constructor() {
|
|
9
12
|
super(...arguments);
|
|
@@ -14,6 +17,38 @@ const WebServerStepper = class WebServerStepper extends defs_1.AStepper {
|
|
|
14
17
|
},
|
|
15
18
|
};
|
|
16
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
|
+
},
|
|
17
52
|
isListening: {
|
|
18
53
|
gwta: 'webserver is listening',
|
|
19
54
|
action: async () => {
|
|
@@ -43,6 +78,18 @@ const WebServerStepper = class WebServerStepper extends defs_1.AStepper {
|
|
|
43
78
|
}
|
|
44
79
|
},
|
|
45
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
|
+
};
|
|
46
93
|
}
|
|
47
94
|
setWorld(world, steppers) {
|
|
48
95
|
super.setWorld(world, steppers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server-stepper.js","sourceRoot":"","sources":["../src/web-server-stepper.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"web-server-stepper.js","sourceRoot":"","sources":["../src/web-server-stepper.ts"],"names":[],"mappings":";;AAAA,sDAAuH;AACvH,sDAAwG;AAExG,iCAAgD;AAChD,qDAA+D;AAC/D,gFAA6E;AAC7E,gFAAuE;AACvE,0DAA0D;AAE1D,MAAM,gBAAgB,GAAG,MAAM,gBAAiB,SAAQ,eAAQ;IAA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