@xeno-js/core 1.2.10 → 1.2.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 +445 -456
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,456 +1,445 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="logo/logo.png" alt="Xeno.JS Logo" width="140" />
|
|
3
|
-
|
|
4
|
-
<h1>Xeno.JS</h1>
|
|
5
|
-
<p><strong>The application architecture framework for TypeScript.</strong></p>
|
|
6
|
-
<p>Build long-lived applications with explicit dependency injection, DDD, CQRS, and transport-independent business logic.</p>
|
|
7
|
-
|
|
8
|
-
<p>
|
|
9
|
-
<a href="https://www.npmjs.com/package/@xeno-js/core"><img src="https://img.shields.io/npm/v/@xeno-js/core?style=flat-square" alt="NPM Version" /></a>
|
|
10
|
-
<a href="https://github.com/xeno-js/xeno-js"><img src="https://img.shields.io/badge/Powered%20by-Xeno-blueviolet?style=flat-square" alt="Powered by Xeno" /></a>
|
|
11
|
-
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License: MIT" /></a>
|
|
12
|
-
<a href="https://buymeacoffee.com/xenojs">
|
|
13
|
-
<img src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-FFdd00?style=flat-square&logo=buy-me-a-coffee&logoColor=black" alt="Buy Me A Coffee" />
|
|
14
|
-
</a>
|
|
15
|
-
</p>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## What is Xeno?
|
|
21
|
-
|
|
22
|
-
Xeno.JS is a TypeScript application architecture framework for Node.js.
|
|
23
|
-
|
|
24
|
-
It provides explicit building blocks for applications organized around:
|
|
25
|
-
|
|
26
|
-
- **Dependency Injection** with explicit service registration and lifetimes
|
|
27
|
-
- **Domain-Driven Design (DDD)** and domain/application boundaries
|
|
28
|
-
- **CQRS** with commands, queries, handlers, and composable pipelines
|
|
29
|
-
- **Request context** built around asynchronous execution context
|
|
30
|
-
- **Repositories and data sources** that keep persistence behind application
|
|
31
|
-
boundaries
|
|
32
|
-
- **Infrastructure adapters** for databases, Redis, authentication, logging,
|
|
33
|
-
resilience, and other integrations
|
|
34
|
-
|
|
35
|
-
The goal is simple: **make application architecture explicit in code.**
|
|
36
|
-
|
|
37
|
-
Xeno.JS is not tied to a specific HTTP server. Your application layer can remain
|
|
38
|
-
independent from the transport that delivers a request.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Why Xeno?
|
|
43
|
-
|
|
44
|
-
### 01 — Explicit Architecture
|
|
45
|
-
|
|
46
|
-
**Your dependency graph is code.**
|
|
47
|
-
|
|
48
|
-
Xeno.JS does not require decorators, runtime scanning, or implicit dependency
|
|
49
|
-
discovery. Services are registered explicitly, and their lifetimes are visible
|
|
50
|
-
at the composition root.
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
services.addScoped('USER_REPOSITORY', (container) => {
|
|
54
|
-
return new UserRepository(
|
|
55
|
-
container.resolve('USER_DATA_SOURCE'),
|
|
56
|
-
container.resolve('USER_MAPPER'),
|
|
57
|
-
)
|
|
58
|
-
})
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
This makes the composition of the application easier to inspect, test, and
|
|
62
|
-
reason about.
|
|
63
|
-
|
|
64
|
-
### 02 — Transport Independence
|
|
65
|
-
|
|
66
|
-
Business logic should not belong to your HTTP framework.
|
|
67
|
-
|
|
68
|
-
Xeno.JS keeps application concerns separate from delivery mechanisms, allowing
|
|
69
|
-
the same application architecture to be hosted behind transports such as
|
|
70
|
-
Fastify, Hono, Express, or other adapters.
|
|
71
|
-
|
|
72
|
-
```text
|
|
73
|
-
HTTP / CLI / Worker / Lambda
|
|
74
|
-
|
|
|
75
|
-
v
|
|
76
|
-
Presentation
|
|
77
|
-
|
|
|
78
|
-
v
|
|
79
|
-
Application
|
|
80
|
-
Commands / Queries
|
|
81
|
-
|
|
|
82
|
-
v
|
|
83
|
-
Domain
|
|
84
|
-
|
|
|
85
|
-
v
|
|
86
|
-
Infrastructure
|
|
87
|
-
DB / Redis / APIs
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 03 — CQRS as an Application Primitive
|
|
91
|
-
|
|
92
|
-
Commands and queries are first-class application concepts.
|
|
93
|
-
|
|
94
|
-
Pipelines can compose cross-cutting behavior around execution, such as:
|
|
95
|
-
|
|
96
|
-
- authorization
|
|
97
|
-
- idempotency
|
|
98
|
-
- concurrency control
|
|
99
|
-
- caching
|
|
100
|
-
- resilience policies
|
|
101
|
-
- request context
|
|
102
|
-
|
|
103
|
-
This keeps cross-cutting concerns out of individual handlers.
|
|
104
|
-
|
|
105
|
-
### 04 — Explicit Lifetimes and Request Boundaries
|
|
106
|
-
|
|
107
|
-
Xeno.JS distinguishes service lifetimes such as singleton, scoped, and transient
|
|
108
|
-
services.
|
|
109
|
-
|
|
110
|
-
Request-scoped dependencies are resolved inside an explicit application scope,
|
|
111
|
-
while request metadata can be carried through asynchronous execution using
|
|
112
|
-
`AsyncLocalStorage`.
|
|
113
|
-
|
|
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
|
-
|
|
118
|
-
### 05 — Infrastructure Stays Outside the Domain
|
|
119
|
-
|
|
120
|
-
Database clients, Redis, HTTP clients, authentication providers, loggers, and
|
|
121
|
-
other infrastructure integrations are composed at the edge of the application.
|
|
122
|
-
|
|
123
|
-
Your domain and application code can depend on contracts instead of concrete
|
|
124
|
-
infrastructure.
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Architecture
|
|
129
|
-
|
|
130
|
-
A typical Xeno.JS application can be organized like this:
|
|
131
|
-
|
|
132
|
-
```text
|
|
133
|
-
+------------------------------------------+
|
|
134
|
-
| Presentation |
|
|
135
|
-
| HTTP / CLI / Workers / Lambda |
|
|
136
|
-
+---------------------+--------------------+
|
|
137
|
-
|
|
|
138
|
-
v
|
|
139
|
-
+------------------------------------------+
|
|
140
|
-
| Application |
|
|
141
|
-
| Commands / Queries / Handlers / Pipes |
|
|
142
|
-
+---------------------+--------------------+
|
|
143
|
-
|
|
|
144
|
-
v
|
|
145
|
-
+------------------------------------------+
|
|
146
|
-
| Domain |
|
|
147
|
-
| Entities / Policies / Rules |
|
|
148
|
-
+---------------------+--------------------+
|
|
149
|
-
|
|
|
150
|
-
v
|
|
151
|
-
+------------------------------------------+
|
|
152
|
-
| Infrastructure |
|
|
153
|
-
| DB / Redis / APIs / Auth / Logs |
|
|
154
|
-
+------------------------------------------+
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Xeno's core is focused on composition and application architecture.
|
|
158
|
-
Infrastructure capabilities can be enabled only when they are needed.
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Core Concepts
|
|
163
|
-
|
|
164
|
-
| Concept | Purpose |
|
|
165
|
-
| ------------------ | --------------------------------------------------------- |
|
|
166
|
-
| `AppBuilder` | Composition root for assembling an application |
|
|
167
|
-
| `ServiceContainer` | Explicit dependency injection and service lifetimes |
|
|
168
|
-
| `CQRS` | Commands, queries, handlers, and mediator-based execution |
|
|
169
|
-
| `Pipelines` | Cross-cutting behavior around application execution |
|
|
170
|
-
| `Request Context` | Request metadata across asynchronous execution |
|
|
171
|
-
| `Repository` | Application-facing persistence abstraction |
|
|
172
|
-
| `DataSource` | Infrastructure-facing data access implementation |
|
|
173
|
-
| `Module` | Explicit registration of related capabilities |
|
|
174
|
-
| `Result` | Typed success/failure flow for application operations |
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## Installation
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
npm install @xeno-js/core
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Install only the integrations your application uses. Xeno.JS exposes optional
|
|
185
|
-
infrastructure dependencies for capabilities such as databases, Redis, logging,
|
|
186
|
-
resilience, and authentication.
|
|
187
|
-
|
|
188
|
-
For example:
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
npm install zod pino cockatiel drizzle-orm
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## A Small Example
|
|
197
|
-
|
|
198
|
-
The composition root is explicit:
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
// src/bootstrap.ts
|
|
202
|
-
import { AppBuilder } from '@xeno-js/core'
|
|
203
|
-
|
|
204
|
-
const app = new AppBuilder().addServices((services) => {
|
|
205
|
-
services.addScoped('USER_REPOSITORY', (container) => {
|
|
206
|
-
return new UserRepository(container.resolve('USER_DATA_SOURCE'))
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
services.addScoped('FIND_USER_HANDLER', (container) => {
|
|
210
|
-
return new FindUserHandler(container.resolve('USER_REPOSITORY'))
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
services.addTransient('FIND_USER_CONTROLLER', (c) => {
|
|
214
|
-
return new FindUserController(
|
|
215
|
-
c.resolve(TOKENS.REQUEST_CONTEXT),
|
|
216
|
-
c.resolve(TOKENS.MEDIATOR),
|
|
217
|
-
)
|
|
218
|
-
})
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
await app.build()
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
The transport remains outside the application composition:
|
|
225
|
-
|
|
226
|
-
> ⚠️ **Implementation note: Example using Fastify** The following snippet uses
|
|
227
|
-
> **Fastify** solely for demonstration purposes to illustrate the transport
|
|
228
|
-
> layer. Thanks to the framework's agnostic architecture, the underlying logic
|
|
229
|
-
> (`container` and `handler`) remains unchanged regardless of the chosen HTTP
|
|
230
|
-
> system (e.g., Express, Koa) or interface (CLI, gRPC).
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
233
|
-
import Fastify from 'fastify'
|
|
234
|
-
import { app } from './bootstrap'
|
|
235
|
-
|
|
236
|
-
const fastify = Fastify({ logger: true })
|
|
237
|
-
|
|
238
|
-
fastify.get('/users/:id', async (req, reply) => {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
Xeno.JS
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
```bash
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
and sponsorship channels documented on the website:
|
|
447
|
-
|
|
448
|
-
**[Support Xeno](https://www.xeno-js.it/docs/support-us)**
|
|
449
|
-
|
|
450
|
-
---
|
|
451
|
-
|
|
452
|
-
## License
|
|
453
|
-
|
|
454
|
-
Copyright (c) 2026 Xeno.
|
|
455
|
-
|
|
456
|
-
Licensed under the [MIT License](LICENSE).
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="logo/logo.png" alt="Xeno.JS Logo" width="140" />
|
|
3
|
+
|
|
4
|
+
<h1>Xeno.JS</h1>
|
|
5
|
+
<p><strong>The application architecture framework for TypeScript.</strong></p>
|
|
6
|
+
<p>Build long-lived applications with explicit dependency injection, DDD, CQRS, and transport-independent business logic.</p>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@xeno-js/core"><img src="https://img.shields.io/npm/v/@xeno-js/core?style=flat-square" alt="NPM Version" /></a>
|
|
10
|
+
<a href="https://github.com/xeno-js/xeno-js"><img src="https://img.shields.io/badge/Powered%20by-Xeno-blueviolet?style=flat-square" alt="Powered by Xeno" /></a>
|
|
11
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License: MIT" /></a>
|
|
12
|
+
<a href="https://buymeacoffee.com/xenojs">
|
|
13
|
+
<img src="https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-FFdd00?style=flat-square&logo=buy-me-a-coffee&logoColor=black" alt="Buy Me A Coffee" />
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What is Xeno?
|
|
21
|
+
|
|
22
|
+
Xeno.JS is a TypeScript application architecture framework for Node.js.
|
|
23
|
+
|
|
24
|
+
It provides explicit building blocks for applications organized around:
|
|
25
|
+
|
|
26
|
+
- **Dependency Injection** with explicit service registration and lifetimes
|
|
27
|
+
- **Domain-Driven Design (DDD)** and domain/application boundaries
|
|
28
|
+
- **CQRS** with commands, queries, handlers, and composable pipelines
|
|
29
|
+
- **Request context** built around asynchronous execution context
|
|
30
|
+
- **Repositories and data sources** that keep persistence behind application
|
|
31
|
+
boundaries
|
|
32
|
+
- **Infrastructure adapters** for databases, Redis, authentication, logging,
|
|
33
|
+
resilience, and other integrations
|
|
34
|
+
|
|
35
|
+
The goal is simple: **make application architecture explicit in code.**
|
|
36
|
+
|
|
37
|
+
Xeno.JS is not tied to a specific HTTP server. Your application layer can remain
|
|
38
|
+
independent from the transport that delivers a request.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Why Xeno?
|
|
43
|
+
|
|
44
|
+
### 01 — Explicit Architecture
|
|
45
|
+
|
|
46
|
+
**Your dependency graph is code.**
|
|
47
|
+
|
|
48
|
+
Xeno.JS does not require decorators, runtime scanning, or implicit dependency
|
|
49
|
+
discovery. Services are registered explicitly, and their lifetimes are visible
|
|
50
|
+
at the composition root.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
services.addScoped('USER_REPOSITORY', (container) => {
|
|
54
|
+
return new UserRepository(
|
|
55
|
+
container.resolve('USER_DATA_SOURCE'),
|
|
56
|
+
container.resolve('USER_MAPPER'),
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This makes the composition of the application easier to inspect, test, and
|
|
62
|
+
reason about.
|
|
63
|
+
|
|
64
|
+
### 02 — Transport Independence
|
|
65
|
+
|
|
66
|
+
Business logic should not belong to your HTTP framework.
|
|
67
|
+
|
|
68
|
+
Xeno.JS keeps application concerns separate from delivery mechanisms, allowing
|
|
69
|
+
the same application architecture to be hosted behind transports such as
|
|
70
|
+
Fastify, Hono, Express, or other adapters.
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
HTTP / CLI / Worker / Lambda
|
|
74
|
+
|
|
|
75
|
+
v
|
|
76
|
+
Presentation
|
|
77
|
+
|
|
|
78
|
+
v
|
|
79
|
+
Application
|
|
80
|
+
Commands / Queries
|
|
81
|
+
|
|
|
82
|
+
v
|
|
83
|
+
Domain
|
|
84
|
+
|
|
|
85
|
+
v
|
|
86
|
+
Infrastructure
|
|
87
|
+
DB / Redis / APIs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 03 — CQRS as an Application Primitive
|
|
91
|
+
|
|
92
|
+
Commands and queries are first-class application concepts.
|
|
93
|
+
|
|
94
|
+
Pipelines can compose cross-cutting behavior around execution, such as:
|
|
95
|
+
|
|
96
|
+
- authorization
|
|
97
|
+
- idempotency
|
|
98
|
+
- concurrency control
|
|
99
|
+
- caching
|
|
100
|
+
- resilience policies
|
|
101
|
+
- request context
|
|
102
|
+
|
|
103
|
+
This keeps cross-cutting concerns out of individual handlers.
|
|
104
|
+
|
|
105
|
+
### 04 — Explicit Lifetimes and Request Boundaries
|
|
106
|
+
|
|
107
|
+
Xeno.JS distinguishes service lifetimes such as singleton, scoped, and transient
|
|
108
|
+
services.
|
|
109
|
+
|
|
110
|
+
Request-scoped dependencies are resolved inside an explicit application scope,
|
|
111
|
+
while request metadata can be carried through asynchronous execution using
|
|
112
|
+
`AsyncLocalStorage`.
|
|
113
|
+
|
|
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
|
+
|
|
118
|
+
### 05 — Infrastructure Stays Outside the Domain
|
|
119
|
+
|
|
120
|
+
Database clients, Redis, HTTP clients, authentication providers, loggers, and
|
|
121
|
+
other infrastructure integrations are composed at the edge of the application.
|
|
122
|
+
|
|
123
|
+
Your domain and application code can depend on contracts instead of concrete
|
|
124
|
+
infrastructure.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Architecture
|
|
129
|
+
|
|
130
|
+
A typical Xeno.JS application can be organized like this:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
+------------------------------------------+
|
|
134
|
+
| Presentation |
|
|
135
|
+
| HTTP / CLI / Workers / Lambda |
|
|
136
|
+
+---------------------+--------------------+
|
|
137
|
+
|
|
|
138
|
+
v
|
|
139
|
+
+------------------------------------------+
|
|
140
|
+
| Application |
|
|
141
|
+
| Commands / Queries / Handlers / Pipes |
|
|
142
|
+
+---------------------+--------------------+
|
|
143
|
+
|
|
|
144
|
+
v
|
|
145
|
+
+------------------------------------------+
|
|
146
|
+
| Domain |
|
|
147
|
+
| Entities / Policies / Rules |
|
|
148
|
+
+---------------------+--------------------+
|
|
149
|
+
|
|
|
150
|
+
v
|
|
151
|
+
+------------------------------------------+
|
|
152
|
+
| Infrastructure |
|
|
153
|
+
| DB / Redis / APIs / Auth / Logs |
|
|
154
|
+
+------------------------------------------+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Xeno's core is focused on composition and application architecture.
|
|
158
|
+
Infrastructure capabilities can be enabled only when they are needed.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Core Concepts
|
|
163
|
+
|
|
164
|
+
| Concept | Purpose |
|
|
165
|
+
| ------------------ | --------------------------------------------------------- |
|
|
166
|
+
| `AppBuilder` | Composition root for assembling an application |
|
|
167
|
+
| `ServiceContainer` | Explicit dependency injection and service lifetimes |
|
|
168
|
+
| `CQRS` | Commands, queries, handlers, and mediator-based execution |
|
|
169
|
+
| `Pipelines` | Cross-cutting behavior around application execution |
|
|
170
|
+
| `Request Context` | Request metadata across asynchronous execution |
|
|
171
|
+
| `Repository` | Application-facing persistence abstraction |
|
|
172
|
+
| `DataSource` | Infrastructure-facing data access implementation |
|
|
173
|
+
| `Module` | Explicit registration of related capabilities |
|
|
174
|
+
| `Result` | Typed success/failure flow for application operations |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Installation
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm install @xeno-js/core
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Install only the integrations your application uses. Xeno.JS exposes optional
|
|
185
|
+
infrastructure dependencies for capabilities such as databases, Redis, logging,
|
|
186
|
+
resilience, and authentication.
|
|
187
|
+
|
|
188
|
+
For example:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm install zod pino cockatiel drizzle-orm
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## A Small Example
|
|
197
|
+
|
|
198
|
+
The composition root is explicit:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// src/bootstrap.ts
|
|
202
|
+
import { AppBuilder } from '@xeno-js/core'
|
|
203
|
+
|
|
204
|
+
const app = new AppBuilder().addServices((services) => {
|
|
205
|
+
services.addScoped('USER_REPOSITORY', (container) => {
|
|
206
|
+
return new UserRepository(container.resolve('USER_DATA_SOURCE'))
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
services.addScoped('FIND_USER_HANDLER', (container) => {
|
|
210
|
+
return new FindUserHandler(container.resolve('USER_REPOSITORY'))
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
services.addTransient('FIND_USER_CONTROLLER', (c) => {
|
|
214
|
+
return new FindUserController(
|
|
215
|
+
c.resolve(TOKENS.REQUEST_CONTEXT),
|
|
216
|
+
c.resolve(TOKENS.MEDIATOR),
|
|
217
|
+
)
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
await app.build()
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The transport remains outside the application composition:
|
|
225
|
+
|
|
226
|
+
> ⚠️ **Implementation note: Example using Fastify** The following snippet uses
|
|
227
|
+
> **Fastify** solely for demonstration purposes to illustrate the transport
|
|
228
|
+
> layer. Thanks to the framework's agnostic architecture, the underlying logic
|
|
229
|
+
> (`container` and `handler`) remains unchanged regardless of the chosen HTTP
|
|
230
|
+
> system (e.g., Express, Koa) or interface (CLI, gRPC).
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import Fastify from 'fastify'
|
|
234
|
+
import { app } from './bootstrap'
|
|
235
|
+
|
|
236
|
+
const fastify = Fastify({ logger: true })
|
|
237
|
+
|
|
238
|
+
fastify.get('/users/:id', async (req, reply) => {
|
|
239
|
+
const action = async () => {
|
|
240
|
+
const controller = ContainerUtils.resolveServiceScoped(
|
|
241
|
+
'FIND_USER_CONTROLLER',
|
|
242
|
+
app,
|
|
243
|
+
)
|
|
244
|
+
return await controller.handle()
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const result = await ContainerUtils.runExecute(req, reply, app, action)
|
|
248
|
+
|
|
249
|
+
return reply.send(result)
|
|
250
|
+
})
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
The HTTP adapter is responsible for HTTP. The application handler is responsible
|
|
254
|
+
for the use case.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## CQRS & Pipelines
|
|
259
|
+
|
|
260
|
+
Cross-cutting behavior can be composed around commands and queries:
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
.addPipeline((config) => {
|
|
264
|
+
config.authorization.policies = {
|
|
265
|
+
FIND_USER_QUERY_HANDLER: {
|
|
266
|
+
roles: ['admin'],
|
|
267
|
+
permissions: ['read'],
|
|
268
|
+
},
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
config.commandBus.idempotency = {
|
|
272
|
+
lockTtlSeconds: 30,
|
|
273
|
+
processedTtlSeconds: 60,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
config.commandBus.concurrency = {
|
|
277
|
+
delayConfig: {
|
|
278
|
+
baseDelayMs: 100,
|
|
279
|
+
maxJitterMs: 500,
|
|
280
|
+
},
|
|
281
|
+
maxRetries: 3,
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
config.queryBus.isEnabled = true
|
|
285
|
+
})
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
The exact pipeline configuration depends on the integrations enabled by your
|
|
289
|
+
application.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Infrastructure & Integrations
|
|
294
|
+
|
|
295
|
+
Xeno.JS Core can be composed with infrastructure such as:
|
|
296
|
+
|
|
297
|
+
- **Database:** Drizzle ORM, PostgreSQL, LibSQL
|
|
298
|
+
- **Cache / distributed coordination:** Redis
|
|
299
|
+
- **Authentication:** Supabase integrations and custom strategies
|
|
300
|
+
- **HTTP clients:** Axios
|
|
301
|
+
- **Resilience:** Cockatiel
|
|
302
|
+
- **Logging:** Console, Pino, Sentry, or custom loggers
|
|
303
|
+
- **Validation:** Zod
|
|
304
|
+
|
|
305
|
+
These integrations are opt-in rather than mandatory parts of the application
|
|
306
|
+
architecture.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## CLI
|
|
311
|
+
|
|
312
|
+
Use the official CLI to scaffold a Xeno.JS application:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
npm install @xeno-js/cli
|
|
316
|
+
xeno-js new my-xeno-app --core
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
See the [CLI documentation](https://www.xeno-js.it/cli/overview).
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Documentation
|
|
324
|
+
|
|
325
|
+
The documentation hub contains the architecture and integration guides:
|
|
326
|
+
|
|
327
|
+
**[xeno-js.it](https://www.xeno-js.it/docs/introduction)**
|
|
328
|
+
|
|
329
|
+
Recommended starting points:
|
|
330
|
+
|
|
331
|
+
- [Introduction](https://www.xeno-js.it/docs/introduction)
|
|
332
|
+
- [Fundamentals](https://www.xeno-js.it/docs/fundamentals/overview)
|
|
333
|
+
- [Dependency Injection](https://www.xeno-js.it/docs/dependency-injection/service-container)
|
|
334
|
+
- [CQRS](https://www.xeno-js.it/docs/application/cqrs/overview)
|
|
335
|
+
- [Pipelines](https://www.xeno-js.it/docs/application/overview)
|
|
336
|
+
- [CLI](https://www.xeno-js.it/docs/cli/overview)
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Ecosystem
|
|
341
|
+
|
|
342
|
+
Xeno.JS is designed as an ecosystem rather than a single monolithic package:
|
|
343
|
+
|
|
344
|
+
| Package | Role |
|
|
345
|
+
| ----------------- | ----------------------------------------- |
|
|
346
|
+
| `@xeno-js/core` | Application architecture and backend core |
|
|
347
|
+
| `@xeno-js/shared` | Shared contracts and types |
|
|
348
|
+
| `@xeno-js/vue` | Vue integration |
|
|
349
|
+
| `@xeno-js/cli` | Project scaffolding and developer tooling |
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## What Xeno.JS Is Not
|
|
354
|
+
|
|
355
|
+
Xeno.JS is not primarily an HTTP framework.
|
|
356
|
+
|
|
357
|
+
If you are looking for a framework centered on routing, controllers, middleware,
|
|
358
|
+
and server lifecycle, there are excellent options already available in the
|
|
359
|
+
Node.js ecosystem.
|
|
360
|
+
|
|
361
|
+
Xeno.JS focuses on the layer above transport:
|
|
362
|
+
|
|
363
|
+
> **How should a TypeScript application be structured so that its business
|
|
364
|
+
> logic, dependencies, and infrastructure boundaries remain explicit as the
|
|
365
|
+
> application grows?**
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Production Considerations
|
|
370
|
+
|
|
371
|
+
Xeno.JS provides architectural primitives, but application correctness still
|
|
372
|
+
depends on how those primitives are composed.
|
|
373
|
+
|
|
374
|
+
Before deploying an application, test the behaviors that matter to your
|
|
375
|
+
workload, especially:
|
|
376
|
+
|
|
377
|
+
- request and transaction isolation
|
|
378
|
+
- service lifetime boundaries
|
|
379
|
+
- authorization policies
|
|
380
|
+
- idempotency semantics
|
|
381
|
+
- concurrency behavior
|
|
382
|
+
- cache consistency
|
|
383
|
+
- failure and retry behavior
|
|
384
|
+
- trusted proxy / client IP configuration
|
|
385
|
+
- database transaction boundaries
|
|
386
|
+
|
|
387
|
+
The framework is designed to make these boundaries explicit rather than hide
|
|
388
|
+
them behind conventions.
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Contributing
|
|
393
|
+
|
|
394
|
+
Contributions are welcome.
|
|
395
|
+
|
|
396
|
+
Development happens from feature branches targeting `develop`.
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
git checkout develop
|
|
400
|
+
git pull origin develop
|
|
401
|
+
git checkout -b feat/your-feature
|
|
402
|
+
|
|
403
|
+
npm install
|
|
404
|
+
npm run check
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
We use Conventional Commits:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
feat(scope): add new feature
|
|
411
|
+
fix(scope): resolve bug
|
|
412
|
+
chore(scope): update dependencies
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Before opening a pull request, run:
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
npm run check
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
| Command | Description |
|
|
422
|
+
| ----------------------- | ------------------------ |
|
|
423
|
+
| `npm run build` | Build the package |
|
|
424
|
+
| `npm run typecheck` | TypeScript type checking |
|
|
425
|
+
| `npm run lint` | ESLint |
|
|
426
|
+
| `npm run format:check` | Prettier validation |
|
|
427
|
+
| `npm run test` | Vitest test suite |
|
|
428
|
+
| `npm run test:coverage` | Test suite with coverage |
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Support
|
|
433
|
+
|
|
434
|
+
If Xeno.JS is useful to you, you can support the project through the community
|
|
435
|
+
and sponsorship channels documented on the website:
|
|
436
|
+
|
|
437
|
+
**[Support Xeno](https://www.xeno-js.it/support-us)**
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## License
|
|
442
|
+
|
|
443
|
+
Copyright (c) 2026 Xeno.
|
|
444
|
+
|
|
445
|
+
Licensed under the [MIT License](LICENSE).
|