@xeno-js/core 0.1.11 → 0.1.12
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 +36 -20
- package/dist/index.cjs +6 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,9 +111,9 @@ Request-scoped dependencies are resolved inside an explicit application scope,
|
|
|
111
111
|
while request metadata can be carried through asynchronous execution using
|
|
112
112
|
`AsyncLocalStorage`.
|
|
113
113
|
|
|
114
|
-
Database transaction state is scoped to the same application boundary,
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
Database transaction state is scoped to the same application boundary, allowing
|
|
115
|
+
`UnitOfWork` and `DbContext` to operate against the transaction associated with
|
|
116
|
+
the current scope.
|
|
117
117
|
|
|
118
118
|
### 05 — Infrastructure Stays Outside the Domain
|
|
119
119
|
|
|
@@ -210,31 +210,47 @@ const app = new AppBuilder().addServices((services) => {
|
|
|
210
210
|
})
|
|
211
211
|
|
|
212
212
|
services.addTransient('FIND_USER_CONTROLLER', (c) => {
|
|
213
|
-
return new FindUserHandler(
|
|
213
|
+
return new FindUserHandler(
|
|
214
|
+
c.resolve(TOKENS.REQUEST_CONTEXT),
|
|
215
|
+
c.resolve(TOKENS.MEDIATOR),
|
|
216
|
+
)
|
|
214
217
|
})
|
|
215
218
|
})
|
|
216
219
|
```
|
|
217
220
|
|
|
218
221
|
The transport remains outside the application composition:
|
|
219
222
|
|
|
220
|
-
> ⚠️ **Implementation note: Example using Fastify**
|
|
221
|
-
>
|
|
223
|
+
> ⚠️ **Implementation note: Example using Fastify** The following snippet uses
|
|
224
|
+
> **Fastify** solely for demonstration purposes to illustrate the transport
|
|
225
|
+
> layer. Thanks to the framework's agnostic architecture, the underlying logic
|
|
226
|
+
> (`container` and `handler`) remains unchanged regardless of the chosen HTTP
|
|
227
|
+
> system (e.g., Express, Koa) or interface (CLI, gRPC).
|
|
222
228
|
|
|
223
229
|
```typescript
|
|
224
|
-
import Fastify from 'fastify'
|
|
225
|
-
import { builder } from './bootstrap'
|
|
230
|
+
import Fastify from 'fastify'
|
|
231
|
+
import { builder } from './bootstrap'
|
|
226
232
|
|
|
227
|
-
const app = Fastify({ logger: true })
|
|
233
|
+
const app = Fastify({ logger: true })
|
|
228
234
|
|
|
229
235
|
app.get('/users/:id', async (req, reply) => {
|
|
230
236
|
const endpoint = req.url
|
|
231
|
-
const container = await builder.build()
|
|
237
|
+
const container = await builder.build()
|
|
232
238
|
const action = async () => {
|
|
233
|
-
|
|
234
|
-
|
|
239
|
+
const controller = ContainerUtils.resolveServiceScoped(
|
|
240
|
+
'FIND_USER_CONTROLLER',
|
|
241
|
+
container,
|
|
242
|
+
)
|
|
243
|
+
return await controller.handle()
|
|
235
244
|
}
|
|
236
245
|
|
|
237
|
-
const result = await ContainerUtils.runExecute(
|
|
246
|
+
const result = await ContainerUtils.runExecute(
|
|
247
|
+
endpoint,
|
|
248
|
+
req.method,
|
|
249
|
+
req.headers,
|
|
250
|
+
{ reply, req },
|
|
251
|
+
container,
|
|
252
|
+
action,
|
|
253
|
+
)
|
|
238
254
|
|
|
239
255
|
return reply.send(result)
|
|
240
256
|
})
|
|
@@ -319,13 +335,13 @@ The documentation hub contains the architecture and integration guides:
|
|
|
319
335
|
Recommended starting points:
|
|
320
336
|
|
|
321
337
|
- [Introduction](https://www.xeno-js.it/introduction)
|
|
322
|
-
- [
|
|
323
|
-
- [Dependency Injection](https://www.xeno-js.it/
|
|
324
|
-
- [CQRS](https://www.xeno-js.it/
|
|
325
|
-
- [Pipelines](https://www.xeno-js.it/
|
|
326
|
-
- [Request Lifecycle](https://www.xeno-js.it/
|
|
327
|
-
- [
|
|
328
|
-
- [CLI](https://www.xeno-js.it/cli/overview)
|
|
338
|
+
- [Fundamentals](https://www.xeno-js.it/docs/core/overview)
|
|
339
|
+
- [Dependency Injection](https://www.xeno-js.it/docs/core/fundamentals/app-builder)
|
|
340
|
+
- [CQRS](https://www.xeno-js.it/docs/core/fundamentals/command-query)
|
|
341
|
+
- [Pipelines](https://www.xeno-js.it/docs/core/cqrs/overview)
|
|
342
|
+
- [Request Lifecycle](https://www.xeno-js.it/docs/core/fundamentals/service-container)
|
|
343
|
+
- [Middleware](https://www.xeno-js.it/docs/core/fundamentals/middleware)
|
|
344
|
+
- [CLI](https://www.xeno-js.it/docs/cli/overview)
|
|
329
345
|
|
|
330
346
|
---
|
|
331
347
|
|
package/dist/index.cjs
CHANGED
|
@@ -2419,9 +2419,7 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2419
2419
|
}
|
|
2420
2420
|
}
|
|
2421
2421
|
if (isNetworkError) return true;
|
|
2422
|
-
if (import_shared53.Guards.isDefined(status))
|
|
2423
|
-
return status === 408 || status === 429 || status >= 500 && status < 600;
|
|
2424
|
-
}
|
|
2422
|
+
if (import_shared53.Guards.isDefined(status)) return status === 408 || status >= 500 && status < 600;
|
|
2425
2423
|
return false;
|
|
2426
2424
|
}
|
|
2427
2425
|
isTransientAndIdempotent(error) {
|
|
@@ -3324,8 +3322,8 @@ var init_cqrs_module = __esm({
|
|
|
3324
3322
|
);
|
|
3325
3323
|
if (Guards46.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3326
3324
|
}
|
|
3327
|
-
const commandPipelines = pipelines;
|
|
3328
|
-
const queryPipelines = pipelines;
|
|
3325
|
+
const commandPipelines = [...pipelines];
|
|
3326
|
+
const queryPipelines = [...pipelines];
|
|
3329
3327
|
if (Guards46.isDefined(opts.commandBus.idempotency) || Guards46.isDefined(opts.commandBus.concurrency)) {
|
|
3330
3328
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3331
3329
|
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
@@ -4598,6 +4596,7 @@ var isDisposable = Object.freeze({
|
|
|
4598
4596
|
var AppBuilder = class {
|
|
4599
4597
|
_container = new ServiceContainer();
|
|
4600
4598
|
_configuration;
|
|
4599
|
+
_isBuilded = false;
|
|
4601
4600
|
constructor(container) {
|
|
4602
4601
|
this._container = container ?? new ServiceContainer();
|
|
4603
4602
|
this._container.addSingleton(
|
|
@@ -4965,6 +4964,7 @@ var AppBuilder = class {
|
|
|
4965
4964
|
* @link https://github.com/xeno-js/xeno-js
|
|
4966
4965
|
*/
|
|
4967
4966
|
async build() {
|
|
4967
|
+
if (this._isBuilded) return this._container;
|
|
4968
4968
|
console.info("\u2699\uFE0F Bootstrapping application modules...");
|
|
4969
4969
|
const sortedModules = this._modules.sort((a, b) => a.priority - b.priority);
|
|
4970
4970
|
for (const queued of sortedModules) {
|
|
@@ -4985,6 +4985,7 @@ var AppBuilder = class {
|
|
|
4985
4985
|
}
|
|
4986
4986
|
}
|
|
4987
4987
|
console.info("\u2705 Application modules bootstrapped successfully.");
|
|
4988
|
+
this._isBuilded = true;
|
|
4988
4989
|
return this._container;
|
|
4989
4990
|
}
|
|
4990
4991
|
// ─────────────────────────────────────────────────────────────────────────────
|