@travetto/web-http 8.0.0-alpha.0 → 8.0.0-alpha.1

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/README.md CHANGED
@@ -16,7 +16,7 @@ yarn add @travetto/web-http
16
16
  This module provides basic for running [http](https://nodejs.org/api/http.html). [https](https://nodejs.org/api/https.html) and [http2](https://nodejs.org/api/http2.html) servers, along with support for tls key generation during development.
17
17
 
18
18
  ## Running a Server
19
- By default, the framework provides a default [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/registry/decorator.ts#L98) for [WebHttpServer](https://github.com/travetto/travetto/tree/main/module/web-http/src/types.ts#L19) that will follow default behaviors, and spin up the server.
19
+ By default, the framework provides a default [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/registry/decorator.ts#L27) for [WebHttpServer](https://github.com/travetto/travetto/tree/main/module/web-http/src/types.ts#L19) that will follow default behaviors, and spin up the server.
20
20
 
21
21
  **Terminal: Standard application**
22
22
  ```bash
@@ -123,7 +123,8 @@ export class WebHttpConfig {
123
123
  @Ignore()
124
124
  fetchUrl: string;
125
125
 
126
- async postConstruct(): Promise<void> {
126
+ @PostConstruct()
127
+ async finalizeConfig(): Promise<void> {
127
128
  this.tls ??= (this.httpVersion === '2' || !!this.tlsKeys);
128
129
  this.port = (this.port < 0 ? await NetUtil.getFreePort() : this.port);
129
130
  this.bindAddress ||= NetUtil.getLocalAddress();
@@ -149,7 +150,7 @@ export class WebHttpConfig {
149
150
  ```
150
151
 
151
152
  ### Creating a Custom CLI Entry Point
152
- To customize a Web server, you may need to construct an entry point using the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/registry/decorator.ts#L98) decorator. This could look like:
153
+ To customize a Web server, you may need to construct an entry point using the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/registry/decorator.ts#L27) decorator. This could look like:
153
154
 
154
155
  **Code: Application entry point for Web Applications**
155
156
  ```typescript
@@ -203,7 +204,7 @@ Initialized {
203
204
  }
204
205
  },
205
206
  runtime: {
206
- production: true,
207
+ production: false,
207
208
  role: 'std',
208
209
  debug: false,
209
210
  resourcePaths: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/web-http",
3
- "version": "8.0.0-alpha.0",
3
+ "version": "8.0.0-alpha.1",
4
4
  "type": "module",
5
5
  "description": "Web HTTP Server Support",
6
6
  "keywords": [
@@ -27,11 +27,11 @@
27
27
  "directory": "module/web-http"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/web": "^8.0.0-alpha.0"
30
+ "@travetto/web": "^8.0.0-alpha.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/cli": "^8.0.0-alpha.0",
34
- "@travetto/test": "^8.0.0-alpha.0"
33
+ "@travetto/cli": "^8.0.0-alpha.1",
34
+ "@travetto/test": "^8.0.0-alpha.1"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@travetto/test": {
package/src/config.ts CHANGED
@@ -2,6 +2,7 @@ import { Config, EnvVar } from '@travetto/config';
2
2
  import { Ignore, Secret } from '@travetto/schema';
3
3
  import { RuntimeError, Runtime, RuntimeResources } from '@travetto/runtime';
4
4
  import { NetUtil } from '@travetto/web';
5
+ import { PostConstruct } from '@travetto/di';
5
6
 
6
7
  import type { WebSecureKeyPair } from './types.ts';
7
8
  import { WebTlsUtil } from './tls.ts';
@@ -45,7 +46,8 @@ export class WebHttpConfig {
45
46
  @Ignore()
46
47
  fetchUrl: string;
47
48
 
48
- async postConstruct(): Promise<void> {
49
+ @PostConstruct()
50
+ async finalizeConfig(): Promise<void> {
49
51
  this.tls ??= (this.httpVersion === '2' || !!this.tlsKeys);
50
52
  this.port = (this.port < 0 ? await NetUtil.getFreePort() : this.port);
51
53
  this.bindAddress ||= NetUtil.getLocalAddress();
@@ -1,6 +1,6 @@
1
1
  import { Runtime, toConcrete } from '@travetto/runtime';
2
2
  import { DependencyRegistryIndex } from '@travetto/di';
3
- import { CliCommand, type CliCommandShape } from '@travetto/cli';
3
+ import { CliCommand, CliDebugIpcFlag, CliModuleFlag, CliProfilesFlag, CliRestartOnChangeFlag, type CliCommandShape } from '@travetto/cli';
4
4
  import { NetUtil } from '@travetto/web';
5
5
  import { Registry } from '@travetto/registry';
6
6
 
@@ -9,7 +9,7 @@ import type { WebHttpServer } from '../src/types.ts';
9
9
  /**
10
10
  * Run a web server
11
11
  */
12
- @CliCommand({ runTarget: true, with: { debugIpc: 'optional', restartOnChange: true, module: true, profiles: true } })
12
+ @CliCommand()
13
13
  export class WebHttpCommand implements CliCommandShape {
14
14
 
15
15
  /** Port to run on */
@@ -18,7 +18,19 @@ export class WebHttpCommand implements CliCommandShape {
18
18
  /** Kill conflicting port owner */
19
19
  killConflict?: boolean = Runtime.localDevelopment;
20
20
 
21
- preMain(): void {
21
+ @CliModuleFlag({ short: 'm' })
22
+ module: string;
23
+
24
+ @CliProfilesFlag()
25
+ profile: string[];
26
+
27
+ @CliRestartOnChangeFlag()
28
+ restartOnChange: boolean = true;
29
+
30
+ @CliDebugIpcFlag()
31
+ debugIpc?: boolean;
32
+
33
+ finalize(): void {
22
34
  if (this.port) {
23
35
  process.env.WEB_HTTP_PORT = `${this.port}`;
24
36
  }