@valkyrjaio/valkyrja 26.2.0 → 26.3.0

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": "@valkyrjaio/valkyrja",
3
- "version": "26.2.0",
3
+ "version": "26.3.0",
4
4
  "description": "The Valkyrja Framework.",
5
5
  "keywords": [
6
6
  "framework",
@@ -8,8 +8,8 @@
8
8
  */
9
9
 
10
10
  export class ApplicationInfo {
11
- static readonly VERSION = '26.2.0' as const;
12
- static readonly VERSION_BUILD_DATE_TIME = 'July 24 2026 23:49:19 MST' as const;
11
+ static readonly VERSION = '26.3.0' as const;
12
+ static readonly VERSION_BUILD_DATE_TIME = 'July 25 2026 20:40:59 MST' as const;
13
13
  static readonly ASCII = `
14
14
  _ _ _
15
15
  /\\ /\\__ _| | | ___ _ _ __(_) __ _
@@ -47,18 +47,21 @@ export class Valkyrja implements ApplicationContract {
47
47
  return this.providers;
48
48
  }
49
49
 
50
- const providers: ComponentProviderContract[][] = [];
51
-
52
50
  for (const provider of this.config.providers) {
53
- providers.push(provider.getComponentProviders(this));
54
- providers.push([provider]);
51
+ this.collectProviders(provider);
55
52
  }
56
53
 
57
- this.providers = [...new Set(providers.flat())];
58
-
59
54
  return this.providers;
60
55
  }
61
56
 
57
+ protected collectProviders(provider: ComponentProviderContract): void {
58
+ for (const subProvider of provider.getComponentProviders(this)) {
59
+ this.collectProviders(subProvider);
60
+ }
61
+
62
+ this.providers.push(provider);
63
+ }
64
+
62
65
  getContainerProviders(): ServiceProviderContract[] {
63
66
  if (this.serviceProviders.length > 0) {
64
67
  return this.serviceProviders;
@@ -8,6 +8,11 @@
8
8
  */
9
9
 
10
10
  import { ContainerComponentProvider } from '../../Container/Provider/ContainerComponentProvider.ts';
11
+ import { HttpMessageComponentProvider } from '../../Http/Message/Provider/HttpMessageComponentProvider.ts';
12
+ import { HttpMiddlewareComponentProvider } from '../../Http/Middleware/Provider/HttpMiddlewareComponentProvider.ts';
13
+ import { HttpRoutingCliComponentProvider } from '../../Http/Routing/Provider/HttpRoutingCliComponentProvider.ts';
14
+ import { HttpRoutingComponentProvider } from '../../Http/Routing/Provider/HttpRoutingComponentProvider.ts';
15
+ import { HttpServerComponentProvider } from '../../Http/Server/Provider/HttpServerComponentProvider.ts';
11
16
  import { ApplicationComponentProvider } from './ApplicationComponentProvider.ts';
12
17
 
13
18
  import type { ApplicationContract } from '../Kernel/Contract/ApplicationContract.ts';
@@ -15,6 +20,13 @@ import type { ComponentProviderContract } from './Contract/ComponentProviderCont
15
20
 
16
21
  export class HttpApplicationComponentProvider extends ApplicationComponentProvider {
17
22
  override getComponentProviders(_app: ApplicationContract): ComponentProviderContract[] {
18
- return [new ContainerComponentProvider()];
23
+ return [
24
+ new ContainerComponentProvider(),
25
+ new HttpMessageComponentProvider(),
26
+ new HttpMiddlewareComponentProvider(),
27
+ new HttpRoutingComponentProvider(),
28
+ new HttpRoutingCliComponentProvider(),
29
+ new HttpServerComponentProvider(),
30
+ ];
19
31
  }
20
32
  }
@@ -0,0 +1,39 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { HttpMessageServiceProvider } from './HttpMessageServiceProvider.ts';
11
+
12
+ import type { ApplicationContract } from '../../../Application/Kernel/Contract/ApplicationContract.ts';
13
+ import type { ComponentProviderContract } from '../../../Application/Provider/Contract/ComponentProviderContract.ts';
14
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
15
+ import type { ListenerProviderContract } from '../../../Event/Provider/Contract/ListenerProviderContract.ts';
16
+ import type { CliRouteProviderContract } from '../../../Cli/Routing/Provider/Contract/CliRouteProviderContract.ts';
17
+ import type { HttpRouteProviderContract } from '../../Routing/Provider/Contract/HttpRouteProviderContract.ts';
18
+
19
+ export class HttpMessageComponentProvider implements ComponentProviderContract {
20
+ getComponentProviders(_app: ApplicationContract): ComponentProviderContract[] {
21
+ return [];
22
+ }
23
+
24
+ getContainerProviders(_app: ApplicationContract): ServiceProviderContract[] {
25
+ return [new HttpMessageServiceProvider()];
26
+ }
27
+
28
+ getEventProviders(_app: ApplicationContract): ListenerProviderContract[] {
29
+ return [];
30
+ }
31
+
32
+ getCliProviders(_app: ApplicationContract): CliRouteProviderContract[] {
33
+ return [];
34
+ }
35
+
36
+ getHttpProviders(_app: ApplicationContract): HttpRouteProviderContract[] {
37
+ return [];
38
+ }
39
+ }
@@ -0,0 +1,39 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { HttpMiddlewareServiceProvider } from './HttpMiddlewareServiceProvider.ts';
11
+
12
+ import type { ApplicationContract } from '../../../Application/Kernel/Contract/ApplicationContract.ts';
13
+ import type { ComponentProviderContract } from '../../../Application/Provider/Contract/ComponentProviderContract.ts';
14
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
15
+ import type { ListenerProviderContract } from '../../../Event/Provider/Contract/ListenerProviderContract.ts';
16
+ import type { CliRouteProviderContract } from '../../../Cli/Routing/Provider/Contract/CliRouteProviderContract.ts';
17
+ import type { HttpRouteProviderContract } from '../../Routing/Provider/Contract/HttpRouteProviderContract.ts';
18
+
19
+ export class HttpMiddlewareComponentProvider implements ComponentProviderContract {
20
+ getComponentProviders(_app: ApplicationContract): ComponentProviderContract[] {
21
+ return [];
22
+ }
23
+
24
+ getContainerProviders(_app: ApplicationContract): ServiceProviderContract[] {
25
+ return [new HttpMiddlewareServiceProvider()];
26
+ }
27
+
28
+ getEventProviders(_app: ApplicationContract): ListenerProviderContract[] {
29
+ return [];
30
+ }
31
+
32
+ getCliProviders(_app: ApplicationContract): CliRouteProviderContract[] {
33
+ return [];
34
+ }
35
+
36
+ getHttpProviders(_app: ApplicationContract): HttpRouteProviderContract[] {
37
+ return [];
38
+ }
39
+ }
@@ -0,0 +1,96 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import type { ContainerContract } from '../../../Container/Manager/Contract/ContainerContract.ts';
11
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
12
+ import { HttpMiddlewareServiceId } from '../Constant/HttpMiddlewareServiceId.ts';
13
+ import type { RequestReceivedHandlerContract } from '../Handler/Contract/RequestReceivedHandlerContract.ts';
14
+ import type { ResponseSentHandlerContract } from '../Handler/Contract/ResponseSentHandlerContract.ts';
15
+ import type { RouteDispatchedHandlerContract } from '../Handler/Contract/RouteDispatchedHandlerContract.ts';
16
+ import type { RouteMatchedHandlerContract } from '../Handler/Contract/RouteMatchedHandlerContract.ts';
17
+ import type { RouteNotMatchedHandlerContract } from '../Handler/Contract/RouteNotMatchedHandlerContract.ts';
18
+ import type { SendingResponseHandlerContract } from '../Handler/Contract/SendingResponseHandlerContract.ts';
19
+ import type { ThrowableCaughtHandlerContract } from '../Handler/Contract/ThrowableCaughtHandlerContract.ts';
20
+ import { RequestReceivedHandler } from '../Handler/RequestReceivedHandler.ts';
21
+ import { ResponseSentHandler } from '../Handler/ResponseSentHandler.ts';
22
+ import { RouteDispatchedHandler } from '../Handler/RouteDispatchedHandler.ts';
23
+ import { RouteMatchedHandler } from '../Handler/RouteMatchedHandler.ts';
24
+ import { RouteNotMatchedHandler } from '../Handler/RouteNotMatchedHandler.ts';
25
+ import { SendingResponseHandler } from '../Handler/SendingResponseHandler.ts';
26
+ import { ThrowableCaughtHandler } from '../Handler/ThrowableCaughtHandler.ts';
27
+
28
+ export class HttpMiddlewareServiceProvider implements ServiceProviderContract {
29
+ publishers(): Record<string, (container: ContainerContract) => void> {
30
+ return {
31
+ [HttpMiddlewareServiceId.RequestReceivedHandlerContract]:
32
+ HttpMiddlewareServiceProvider.publishRequestReceivedHandler,
33
+ [HttpMiddlewareServiceId.ThrowableCaughtHandlerContract]:
34
+ HttpMiddlewareServiceProvider.publishThrowableCaughtHandler,
35
+ [HttpMiddlewareServiceId.RouteMatchedHandlerContract]:
36
+ HttpMiddlewareServiceProvider.publishRouteMatchedHandler,
37
+ [HttpMiddlewareServiceId.RouteNotMatchedHandlerContract]:
38
+ HttpMiddlewareServiceProvider.publishRouteNotMatchedHandler,
39
+ [HttpMiddlewareServiceId.RouteDispatchedHandlerContract]:
40
+ HttpMiddlewareServiceProvider.publishRouteDispatchedHandler,
41
+ [HttpMiddlewareServiceId.SendingResponseHandlerContract]:
42
+ HttpMiddlewareServiceProvider.publishSendingResponseHandler,
43
+ [HttpMiddlewareServiceId.ResponseSentHandlerContract]:
44
+ HttpMiddlewareServiceProvider.publishResponseSentHandler,
45
+ };
46
+ }
47
+
48
+ static publishRequestReceivedHandler(this: void, container: ContainerContract): void {
49
+ container.setSingleton<RequestReceivedHandlerContract>(
50
+ HttpMiddlewareServiceId.RequestReceivedHandlerContract,
51
+ new RequestReceivedHandler(container),
52
+ );
53
+ }
54
+
55
+ static publishThrowableCaughtHandler(this: void, container: ContainerContract): void {
56
+ container.setSingleton<ThrowableCaughtHandlerContract>(
57
+ HttpMiddlewareServiceId.ThrowableCaughtHandlerContract,
58
+ new ThrowableCaughtHandler(container),
59
+ );
60
+ }
61
+
62
+ static publishRouteMatchedHandler(this: void, container: ContainerContract): void {
63
+ container.setSingleton<RouteMatchedHandlerContract>(
64
+ HttpMiddlewareServiceId.RouteMatchedHandlerContract,
65
+ new RouteMatchedHandler(container),
66
+ );
67
+ }
68
+
69
+ static publishRouteNotMatchedHandler(this: void, container: ContainerContract): void {
70
+ container.setSingleton<RouteNotMatchedHandlerContract>(
71
+ HttpMiddlewareServiceId.RouteNotMatchedHandlerContract,
72
+ new RouteNotMatchedHandler(container),
73
+ );
74
+ }
75
+
76
+ static publishRouteDispatchedHandler(this: void, container: ContainerContract): void {
77
+ container.setSingleton<RouteDispatchedHandlerContract>(
78
+ HttpMiddlewareServiceId.RouteDispatchedHandlerContract,
79
+ new RouteDispatchedHandler(container),
80
+ );
81
+ }
82
+
83
+ static publishSendingResponseHandler(this: void, container: ContainerContract): void {
84
+ container.setSingleton<SendingResponseHandlerContract>(
85
+ HttpMiddlewareServiceId.SendingResponseHandlerContract,
86
+ new SendingResponseHandler(container),
87
+ );
88
+ }
89
+
90
+ static publishResponseSentHandler(this: void, container: ContainerContract): void {
91
+ container.setSingleton<ResponseSentHandlerContract>(
92
+ HttpMiddlewareServiceId.ResponseSentHandlerContract,
93
+ new ResponseSentHandler(container),
94
+ );
95
+ }
96
+ }
@@ -0,0 +1,39 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { HttpRoutingServiceProvider } from './HttpRoutingServiceProvider.ts';
11
+
12
+ import type { ApplicationContract } from '../../../Application/Kernel/Contract/ApplicationContract.ts';
13
+ import type { ComponentProviderContract } from '../../../Application/Provider/Contract/ComponentProviderContract.ts';
14
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
15
+ import type { ListenerProviderContract } from '../../../Event/Provider/Contract/ListenerProviderContract.ts';
16
+ import type { CliRouteProviderContract } from '../../../Cli/Routing/Provider/Contract/CliRouteProviderContract.ts';
17
+ import type { HttpRouteProviderContract } from './Contract/HttpRouteProviderContract.ts';
18
+
19
+ export class HttpRoutingComponentProvider implements ComponentProviderContract {
20
+ getComponentProviders(_app: ApplicationContract): ComponentProviderContract[] {
21
+ return [];
22
+ }
23
+
24
+ getContainerProviders(_app: ApplicationContract): ServiceProviderContract[] {
25
+ return [new HttpRoutingServiceProvider()];
26
+ }
27
+
28
+ getEventProviders(_app: ApplicationContract): ListenerProviderContract[] {
29
+ return [];
30
+ }
31
+
32
+ getCliProviders(_app: ApplicationContract): CliRouteProviderContract[] {
33
+ return [];
34
+ }
35
+
36
+ getHttpProviders(_app: ApplicationContract): HttpRouteProviderContract[] {
37
+ return [];
38
+ }
39
+ }
@@ -0,0 +1,141 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { ApplicationServiceId } from '../../../Application/Constant/ApplicationServiceId.ts';
11
+ import type { ApplicationContract } from '../../../Application/Kernel/Contract/ApplicationContract.ts';
12
+ import type { ContainerContract } from '../../../Container/Manager/Contract/ContainerContract.ts';
13
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
14
+ import { HttpMessageServiceId } from '../../Message/Constant/HttpMessageServiceId.ts';
15
+ import type { ResponseFactoryContract } from '../../Message/Response/Factory/Contract/ResponseFactoryContract.ts';
16
+ import { HttpMiddlewareServiceId } from '../../Middleware/Constant/HttpMiddlewareServiceId.ts';
17
+ import type { ResponseSentHandlerContract } from '../../Middleware/Handler/Contract/ResponseSentHandlerContract.ts';
18
+ import type { RouteDispatchedHandlerContract } from '../../Middleware/Handler/Contract/RouteDispatchedHandlerContract.ts';
19
+ import type { RouteMatchedHandlerContract } from '../../Middleware/Handler/Contract/RouteMatchedHandlerContract.ts';
20
+ import type { RouteNotMatchedHandlerContract } from '../../Middleware/Handler/Contract/RouteNotMatchedHandlerContract.ts';
21
+ import type { SendingResponseHandlerContract } from '../../Middleware/Handler/Contract/SendingResponseHandlerContract.ts';
22
+ import type { ThrowableCaughtHandlerContract } from '../../Middleware/Handler/Contract/ThrowableCaughtHandlerContract.ts';
23
+ import type { RouteCollectionContract } from '../Collection/Contract/RouteCollectionContract.ts';
24
+ import { RouteCollection } from '../Collection/RouteCollection.ts';
25
+ import { HttpRoutingServiceId } from '../Constant/HttpRoutingServiceId.ts';
26
+ import { HttpRoutingData } from '../Data/HttpRoutingData.ts';
27
+ import type { RouterContract } from '../Dispatcher/Contract/RouterContract.ts';
28
+ import { Router } from '../Dispatcher/Router.ts';
29
+ import type { RoutingResponseFactoryContract } from '../Factory/Contract/RoutingResponseFactoryContract.ts';
30
+ import { RoutingResponseFactory } from '../Factory/RoutingResponseFactory.ts';
31
+ import type { MatcherContract } from '../Matcher/Contract/MatcherContract.ts';
32
+ import { Matcher } from '../Matcher/Matcher.ts';
33
+ import type { ProcessorContract } from '../Processor/Contract/ProcessorContract.ts';
34
+ import { Processor } from '../Processor/Processor.ts';
35
+ import type { UrlContract } from '../Url/Contract/UrlContract.ts';
36
+ import { Url } from '../Url/Url.ts';
37
+
38
+ export class HttpRoutingServiceProvider implements ServiceProviderContract {
39
+ publishers(): Record<string, (container: ContainerContract) => void> {
40
+ return {
41
+ [HttpRoutingServiceId.RouterContract]: HttpRoutingServiceProvider.publishRouter,
42
+ [HttpRoutingServiceId.RouteCollectionContract]: HttpRoutingServiceProvider.publishRouteCollection,
43
+ [HttpRoutingServiceId.MatcherContract]: HttpRoutingServiceProvider.publishMatcher,
44
+ [HttpRoutingServiceId.UrlContract]: HttpRoutingServiceProvider.publishUrl,
45
+ [HttpRoutingServiceId.ProcessorContract]: HttpRoutingServiceProvider.publishProcessor,
46
+ [HttpRoutingServiceId.RoutingResponseFactory]: HttpRoutingServiceProvider.publishResponseFactory,
47
+ [HttpRoutingServiceId.HttpRoutingData]: HttpRoutingServiceProvider.publishData,
48
+ };
49
+ }
50
+
51
+ static publishRouter(this: void, container: ContainerContract): void {
52
+ container.setSingleton<RouterContract>(
53
+ HttpRoutingServiceId.RouterContract,
54
+ new Router(
55
+ container,
56
+ container.getSingleton<MatcherContract>(HttpRoutingServiceId.MatcherContract),
57
+ container.getSingleton<ResponseFactoryContract>(HttpMessageServiceId.ResponseFactoryContract),
58
+ container.getSingleton<ThrowableCaughtHandlerContract>(
59
+ HttpMiddlewareServiceId.ThrowableCaughtHandlerContract,
60
+ ),
61
+ container.getSingleton<RouteMatchedHandlerContract>(
62
+ HttpMiddlewareServiceId.RouteMatchedHandlerContract,
63
+ ),
64
+ container.getSingleton<RouteNotMatchedHandlerContract>(
65
+ HttpMiddlewareServiceId.RouteNotMatchedHandlerContract,
66
+ ),
67
+ container.getSingleton<RouteDispatchedHandlerContract>(
68
+ HttpMiddlewareServiceId.RouteDispatchedHandlerContract,
69
+ ),
70
+ container.getSingleton<SendingResponseHandlerContract>(
71
+ HttpMiddlewareServiceId.SendingResponseHandlerContract,
72
+ ),
73
+ container.getSingleton<ResponseSentHandlerContract>(
74
+ HttpMiddlewareServiceId.ResponseSentHandlerContract,
75
+ ),
76
+ ),
77
+ );
78
+ }
79
+
80
+ static publishRouteCollection(this: void, container: ContainerContract): void {
81
+ const collection = new RouteCollection();
82
+
83
+ container.setSingleton<RouteCollectionContract>(HttpRoutingServiceId.RouteCollectionContract, collection);
84
+
85
+ const app = container.getSingleton<ApplicationContract>(ApplicationServiceId.ApplicationContract);
86
+
87
+ if (app.getDebugMode()) {
88
+ HttpRoutingServiceProvider.publishData(container);
89
+
90
+ return;
91
+ }
92
+
93
+ const data = container.getSingleton<HttpRoutingData>(HttpRoutingServiceId.HttpRoutingData);
94
+
95
+ collection.setFromData(data);
96
+ }
97
+
98
+ static publishMatcher(this: void, container: ContainerContract): void {
99
+ container.setSingleton<MatcherContract>(
100
+ HttpRoutingServiceId.MatcherContract,
101
+ new Matcher(container.getSingleton<RouteCollectionContract>(HttpRoutingServiceId.RouteCollectionContract)),
102
+ );
103
+ }
104
+
105
+ static publishUrl(this: void, container: ContainerContract): void {
106
+ container.setSingleton<UrlContract>(
107
+ HttpRoutingServiceId.UrlContract,
108
+ new Url(container.getSingleton<RouteCollectionContract>(HttpRoutingServiceId.RouteCollectionContract)),
109
+ );
110
+ }
111
+
112
+ static publishProcessor(this: void, container: ContainerContract): void {
113
+ container.setSingleton<ProcessorContract>(HttpRoutingServiceId.ProcessorContract, new Processor());
114
+ }
115
+
116
+ static publishResponseFactory(this: void, container: ContainerContract): void {
117
+ container.setSingleton<RoutingResponseFactoryContract>(
118
+ HttpRoutingServiceId.RoutingResponseFactory,
119
+ new RoutingResponseFactory(
120
+ container.getSingleton<ResponseFactoryContract>(HttpMessageServiceId.ResponseFactoryContract),
121
+ container.getSingleton<UrlContract>(HttpRoutingServiceId.UrlContract),
122
+ ),
123
+ );
124
+ }
125
+
126
+ static publishData(this: void, container: ContainerContract): void {
127
+ const collection = container.getSingleton<RouteCollectionContract>(
128
+ HttpRoutingServiceId.RouteCollectionContract,
129
+ );
130
+ const app = container.getSingleton<ApplicationContract>(ApplicationServiceId.ApplicationContract);
131
+ const processor = container.getSingleton<ProcessorContract>(HttpRoutingServiceId.ProcessorContract);
132
+
133
+ for (const provider of app.getHttpProviders()) {
134
+ for (const route of provider.getRoutes()) {
135
+ collection.add(processor.route(route));
136
+ }
137
+ }
138
+
139
+ container.setSingleton(HttpRoutingServiceId.HttpRoutingData, collection.getData());
140
+ }
141
+ }
@@ -98,11 +98,12 @@ export class RequestHandler implements RequestHandlerContract {
98
98
 
99
99
  const requestAfterMiddleware = this.requestReceivedHandler.requestReceived(request);
100
100
 
101
- if (!('getPath' in requestAfterMiddleware)) {
102
- return requestAfterMiddleware as ResponseContract;
101
+ // If the return value after middleware is a response return it.
102
+ if ('getStatusCode' in requestAfterMiddleware) {
103
+ return requestAfterMiddleware;
103
104
  }
104
105
 
105
- const updatedRequest = requestAfterMiddleware as ServerRequestContract;
106
+ const updatedRequest = requestAfterMiddleware;
106
107
 
107
108
  this.container.setSingleton(HttpMessageServiceId.ServerRequestContract, updatedRequest);
108
109
 
@@ -0,0 +1,39 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { HttpServerServiceProvider } from './HttpServerServiceProvider.ts';
11
+
12
+ import type { ApplicationContract } from '../../../Application/Kernel/Contract/ApplicationContract.ts';
13
+ import type { ComponentProviderContract } from '../../../Application/Provider/Contract/ComponentProviderContract.ts';
14
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
15
+ import type { ListenerProviderContract } from '../../../Event/Provider/Contract/ListenerProviderContract.ts';
16
+ import type { CliRouteProviderContract } from '../../../Cli/Routing/Provider/Contract/CliRouteProviderContract.ts';
17
+ import type { HttpRouteProviderContract } from '../../Routing/Provider/Contract/HttpRouteProviderContract.ts';
18
+
19
+ export class HttpServerComponentProvider implements ComponentProviderContract {
20
+ getComponentProviders(_app: ApplicationContract): ComponentProviderContract[] {
21
+ return [];
22
+ }
23
+
24
+ getContainerProviders(_app: ApplicationContract): ServiceProviderContract[] {
25
+ return [new HttpServerServiceProvider()];
26
+ }
27
+
28
+ getEventProviders(_app: ApplicationContract): ListenerProviderContract[] {
29
+ return [];
30
+ }
31
+
32
+ getCliProviders(_app: ApplicationContract): CliRouteProviderContract[] {
33
+ return [];
34
+ }
35
+
36
+ getHttpProviders(_app: ApplicationContract): HttpRouteProviderContract[] {
37
+ return [];
38
+ }
39
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * This file is part of the Valkyrja package.
3
+ *
4
+ * (c) Melech Mizrachi <melechmizrachi@gmail.com>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { ApplicationServiceId } from '../../../Application/Constant/ApplicationServiceId.ts';
11
+ import type { ApplicationContract } from '../../../Application/Kernel/Contract/ApplicationContract.ts';
12
+ import type { ContainerContract } from '../../../Container/Manager/Contract/ContainerContract.ts';
13
+ import type { ServiceProviderContract } from '../../../Container/Provider/Contract/ServiceProviderContract.ts';
14
+ import { HttpMiddlewareServiceId } from '../../Middleware/Constant/HttpMiddlewareServiceId.ts';
15
+ import type { RequestReceivedHandlerContract } from '../../Middleware/Handler/Contract/RequestReceivedHandlerContract.ts';
16
+ import type { ResponseSentHandlerContract } from '../../Middleware/Handler/Contract/ResponseSentHandlerContract.ts';
17
+ import type { SendingResponseHandlerContract } from '../../Middleware/Handler/Contract/SendingResponseHandlerContract.ts';
18
+ import type { ThrowableCaughtHandlerContract } from '../../Middleware/Handler/Contract/ThrowableCaughtHandlerContract.ts';
19
+ import { HttpRoutingServiceId } from '../../Routing/Constant/HttpRoutingServiceId.ts';
20
+ import type { RouterContract } from '../../Routing/Dispatcher/Contract/RouterContract.ts';
21
+ import { HttpServerServiceId } from '../Constant/HttpServerServiceId.ts';
22
+ import type { RequestHandlerContract } from '../Handler/Contract/RequestHandlerContract.ts';
23
+ import { RequestHandler } from '../Handler/RequestHandler.ts';
24
+
25
+ export class HttpServerServiceProvider implements ServiceProviderContract {
26
+ publishers(): Record<string, (container: ContainerContract) => void> {
27
+ return {
28
+ [HttpServerServiceId.RequestHandlerContract]: HttpServerServiceProvider.publishRequestHandler,
29
+ };
30
+ }
31
+
32
+ static publishRequestHandler(this: void, container: ContainerContract): void {
33
+ const app = container.getSingleton<ApplicationContract>(ApplicationServiceId.ApplicationContract);
34
+
35
+ container.setSingleton<RequestHandlerContract>(
36
+ HttpServerServiceId.RequestHandlerContract,
37
+ new RequestHandler(
38
+ container,
39
+ container.getSingleton<RouterContract>(HttpRoutingServiceId.RouterContract),
40
+ container.getSingleton<RequestReceivedHandlerContract>(
41
+ HttpMiddlewareServiceId.RequestReceivedHandlerContract,
42
+ ),
43
+ container.getSingleton<ThrowableCaughtHandlerContract>(
44
+ HttpMiddlewareServiceId.ThrowableCaughtHandlerContract,
45
+ ),
46
+ container.getSingleton<SendingResponseHandlerContract>(
47
+ HttpMiddlewareServiceId.SendingResponseHandlerContract,
48
+ ),
49
+ container.getSingleton<ResponseSentHandlerContract>(
50
+ HttpMiddlewareServiceId.ResponseSentHandlerContract,
51
+ ),
52
+ app.getDebugMode(),
53
+ ),
54
+ );
55
+ }
56
+ }