@xeno-js/core 0.1.12 → 0.1.13
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 +13 -9
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -198,9 +198,11 @@ npm install zod pino cockatiel drizzle-orm
|
|
|
198
198
|
The composition root is explicit:
|
|
199
199
|
|
|
200
200
|
```typescript
|
|
201
|
+
// src/bootstrap.ts
|
|
201
202
|
import { AppBuilder } from '@xeno-js/core'
|
|
202
203
|
|
|
203
|
-
const app = new AppBuilder()
|
|
204
|
+
const app = new AppBuilder()
|
|
205
|
+
.addServices((services) => {
|
|
204
206
|
services.addScoped('USER_REPOSITORY', (container) => {
|
|
205
207
|
return new UserRepository(container.resolve('USER_DATA_SOURCE'))
|
|
206
208
|
})
|
|
@@ -210,12 +212,14 @@ const app = new AppBuilder().addServices((services) => {
|
|
|
210
212
|
})
|
|
211
213
|
|
|
212
214
|
services.addTransient('FIND_USER_CONTROLLER', (c) => {
|
|
213
|
-
return new
|
|
215
|
+
return new FindUserController(
|
|
214
216
|
c.resolve(TOKENS.REQUEST_CONTEXT),
|
|
215
217
|
c.resolve(TOKENS.MEDIATOR),
|
|
216
218
|
)
|
|
217
219
|
})
|
|
218
220
|
})
|
|
221
|
+
|
|
222
|
+
await app.build()
|
|
219
223
|
```
|
|
220
224
|
|
|
221
225
|
The transport remains outside the application composition:
|
|
@@ -228,17 +232,17 @@ The transport remains outside the application composition:
|
|
|
228
232
|
|
|
229
233
|
```typescript
|
|
230
234
|
import Fastify from 'fastify'
|
|
231
|
-
import {
|
|
235
|
+
import { app } from './bootstrap'
|
|
232
236
|
|
|
233
|
-
const
|
|
237
|
+
const fastify = Fastify({ logger: true })
|
|
234
238
|
|
|
235
|
-
|
|
239
|
+
fastify.get('/users/:id', async (req, reply) => {
|
|
236
240
|
const endpoint = req.url
|
|
237
|
-
|
|
241
|
+
|
|
238
242
|
const action = async () => {
|
|
239
243
|
const controller = ContainerUtils.resolveServiceScoped(
|
|
240
244
|
'FIND_USER_CONTROLLER',
|
|
241
|
-
|
|
245
|
+
app,
|
|
242
246
|
)
|
|
243
247
|
return await controller.handle()
|
|
244
248
|
}
|
|
@@ -248,7 +252,7 @@ app.get('/users/:id', async (req, reply) => {
|
|
|
248
252
|
req.method,
|
|
249
253
|
req.headers,
|
|
250
254
|
{ reply, req },
|
|
251
|
-
|
|
255
|
+
app,
|
|
252
256
|
action,
|
|
253
257
|
)
|
|
254
258
|
|
|
@@ -442,7 +446,7 @@ npm run check
|
|
|
442
446
|
If Xeno is useful to you, you can support the project through the community and
|
|
443
447
|
sponsorship channels documented on the website:
|
|
444
448
|
|
|
445
|
-
**[Support Xeno](https://www.xeno-js.it/support-us)**
|
|
449
|
+
**[Support Xeno](https://www.xeno-js.it/docs/support-us)**
|
|
446
450
|
|
|
447
451
|
---
|
|
448
452
|
|
package/dist/index.cjs
CHANGED
|
@@ -3873,7 +3873,7 @@ var init_rate_limiter_middleware = __esm({
|
|
|
3873
3873
|
error: {
|
|
3874
3874
|
code: import_shared69.ERROR_CODES.TOO_MANY_REQUESTS,
|
|
3875
3875
|
message: import_shared69.ERROR_CODE_MESSAGES[import_shared69.ERROR_CODES.TOO_MANY_REQUESTS],
|
|
3876
|
-
details: `Rate limit exceeded
|
|
3876
|
+
details: `Rate limit exceeded.`,
|
|
3877
3877
|
path: req.path
|
|
3878
3878
|
},
|
|
3879
3879
|
correlationId: tracing?.correlationId ?? import_shared69.GuidHelper.generate(),
|