@travetto/web 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/web",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Declarative support for creating Web Applications",
|
|
6
6
|
"keywords": [
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"directory": "module/web"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^8.0.0-alpha.
|
|
30
|
-
"@travetto/context": "^8.0.0-alpha.
|
|
31
|
-
"@travetto/di": "^8.0.0-alpha.
|
|
32
|
-
"@travetto/registry": "^8.0.0-alpha.
|
|
33
|
-
"@travetto/runtime": "^8.0.0-alpha.
|
|
34
|
-
"@travetto/schema": "^8.0.0-alpha.
|
|
29
|
+
"@travetto/config": "^8.0.0-alpha.1",
|
|
30
|
+
"@travetto/context": "^8.0.0-alpha.1",
|
|
31
|
+
"@travetto/di": "^8.0.0-alpha.1",
|
|
32
|
+
"@travetto/registry": "^8.0.0-alpha.1",
|
|
33
|
+
"@travetto/runtime": "^8.0.0-alpha.1",
|
|
34
|
+
"@travetto/schema": "^8.0.0-alpha.1",
|
|
35
35
|
"find-my-way": "^9.5.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
39
|
-
"@travetto/test": "^8.0.0-alpha.
|
|
40
|
-
"@travetto/transformer": "^8.0.0-alpha.
|
|
38
|
+
"@travetto/cli": "^8.0.0-alpha.1",
|
|
39
|
+
"@travetto/test": "^8.0.0-alpha.1",
|
|
40
|
+
"@travetto/transformer": "^8.0.0-alpha.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@travetto/transformer": {
|
package/src/context.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncContextValue, type AsyncContext } from '@travetto/context';
|
|
2
|
-
import { Inject, Injectable } from '@travetto/di';
|
|
2
|
+
import { Inject, Injectable, PostConstruct } from '@travetto/di';
|
|
3
3
|
import { RuntimeError, castTo, type Class } from '@travetto/runtime';
|
|
4
4
|
|
|
5
5
|
import { WebRequest } from './types/request.ts';
|
|
@@ -20,7 +20,8 @@ export class WebAsyncContext {
|
|
|
20
20
|
return this.#request.get()!;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
@PostConstruct()
|
|
24
|
+
exposeContext(): void {
|
|
24
25
|
this.registerSource(WebRequest, () => this.#request.get());
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -12,6 +12,6 @@ import { ControllerRegistryIndex } from '../registry/registry-index.ts';
|
|
|
12
12
|
export function Controller(path: string) {
|
|
13
13
|
return function <T>(cls: Class<T>): void {
|
|
14
14
|
ControllerRegistryIndex.getForRegister(cls).register({ basePath: path, class: cls, });
|
|
15
|
-
DependencyRegistryIndex.
|
|
15
|
+
DependencyRegistryIndex.registerClass(cls);
|
|
16
16
|
};
|
|
17
17
|
}
|
package/src/interceptor/body.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable, Inject, DependencyRegistryIndex } from '@travetto/di';
|
|
1
|
+
import { Injectable, Inject, DependencyRegistryIndex, PostConstruct } from '@travetto/di';
|
|
2
2
|
import { Config } from '@travetto/config';
|
|
3
3
|
import { toConcrete } from '@travetto/runtime';
|
|
4
4
|
import { Ignore } from '@travetto/schema';
|
|
@@ -63,7 +63,8 @@ export class BodyInterceptor implements WebInterceptor<WebBodyConfig> {
|
|
|
63
63
|
@Inject()
|
|
64
64
|
config: WebBodyConfig;
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
@PostConstruct()
|
|
67
|
+
async loadParsers(): Promise<void> {
|
|
67
68
|
// Load all the parser types
|
|
68
69
|
const instances = await DependencyRegistryIndex.getInstances(toConcrete<BodyContentParser>());
|
|
69
70
|
for (const instance of instances) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable, Inject } from '@travetto/di';
|
|
1
|
+
import { Injectable, Inject, PostConstruct } from '@travetto/di';
|
|
2
2
|
import { Config } from '@travetto/config';
|
|
3
3
|
import { Secret } from '@travetto/schema';
|
|
4
4
|
import { type AsyncContext, AsyncContextValue } from '@travetto/context';
|
|
@@ -78,7 +78,8 @@ export class CookieInterceptor implements WebInterceptor<CookieConfig> {
|
|
|
78
78
|
@Inject()
|
|
79
79
|
context: AsyncContext;
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
@PostConstruct()
|
|
82
|
+
exposeContext(): void {
|
|
82
83
|
this.webAsyncContext.registerSource(CookieJar, () => this.#cookieJar.get());
|
|
83
84
|
this.keyGrip ??= new KeyGrip(this.config.keys ?? []);
|
|
84
85
|
}
|
|
@@ -74,10 +74,10 @@ export class ControllerRegistryIndex implements RegistryIndex {
|
|
|
74
74
|
* @param target Controller class
|
|
75
75
|
*/
|
|
76
76
|
bindContextParamsOnPostConstruct(cls: Class): void {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const bind = (instance: ClassInstance): Promise<void> => this.#bindContextParams(instance);
|
|
78
|
+
DependencyRegistryIndex.registerPostConstruct(cls, {
|
|
79
|
+
operation(this: ClassInstance): Promise<void> { return bind(this); },
|
|
80
|
+
priority: 100
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
package/src/router/base.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Class, toConcrete } from '@travetto/runtime';
|
|
2
|
-
import { DependencyRegistryIndex, Injectable } from '@travetto/di';
|
|
2
|
+
import { DependencyRegistryIndex, Injectable, PostConstruct } from '@travetto/di';
|
|
3
3
|
import { ControllerRegistryIndex } from '@travetto/web';
|
|
4
4
|
|
|
5
5
|
import type { ControllerConfig, EndpointConfig } from '../registry/types.ts';
|
|
@@ -34,7 +34,8 @@ export abstract class BaseWebRouter implements WebRouter {
|
|
|
34
34
|
/**
|
|
35
35
|
* Initialize router, encapsulating common patterns for standard router setup
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
@PostConstruct()
|
|
38
|
+
async registerRoutes(): Promise<void> {
|
|
38
39
|
|
|
39
40
|
this.#interceptors = await DependencyRegistryIndex.getInstances(toConcrete<WebInterceptor>());
|
|
40
41
|
this.#interceptors = EndpointUtil.orderInterceptors(this.#interceptors);
|