@navios/core 1.1.0 → 2.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.
Files changed (237) hide show
  1. package/CHANGELOG.md +85 -13
  2. package/README.md +69 -220
  3. package/lib/async-context-BAdt7bno.d.mts +239 -0
  4. package/lib/async-context-BAdt7bno.d.mts.map +1 -0
  5. package/lib/async-context-RsWmy2Hi.d.cts +239 -0
  6. package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
  7. package/lib/attribute-factory-BW1kgBqf.d.mts +70 -0
  8. package/lib/attribute-factory-BW1kgBqf.d.mts.map +1 -0
  9. package/lib/attribute-factory-DqN4x5XM.d.cts +70 -0
  10. package/lib/attribute-factory-DqN4x5XM.d.cts.map +1 -0
  11. package/lib/attribute-value-BNiJjxl1.mjs +225 -0
  12. package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
  13. package/lib/attribute-value-Cux5HhOL.cjs +314 -0
  14. package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
  15. package/lib/basic-execution-context-5uq2DvEA.cjs +318 -0
  16. package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
  17. package/lib/basic-execution-context-u1VktGoM.mjs +277 -0
  18. package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
  19. package/lib/execution-context-BVSmLkYp.d.cts +71 -0
  20. package/lib/execution-context-BVSmLkYp.d.cts.map +1 -0
  21. package/lib/execution-context-C5F9rojO.d.mts +71 -0
  22. package/lib/execution-context-C5F9rojO.d.mts.map +1 -0
  23. package/lib/execution-context-token--cKS4cJv.cjs +270 -0
  24. package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
  25. package/lib/execution-context-token-Cb3M3Ao0.mjs +223 -0
  26. package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
  27. package/lib/index.cjs +1672 -4426
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +842 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +842 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1559 -4221
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bz83ZnJ5.cjs +173 -0
  44. package/lib/module-Bz83ZnJ5.cjs.map +1 -0
  45. package/lib/module-options-CSqQUSTm.d.mts +51 -0
  46. package/lib/module-options-CSqQUSTm.d.mts.map +1 -0
  47. package/lib/module-options-DSRBri4J.d.cts +51 -0
  48. package/lib/module-options-DSRBri4J.d.cts.map +1 -0
  49. package/lib/module-zPXwR2qp.mjs +138 -0
  50. package/lib/module-zPXwR2qp.mjs.map +1 -0
  51. package/lib/settled-within-B6gpu2XW.cjs +32 -0
  52. package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
  53. package/lib/settled-within-Bc2pj8WB.mjs +21 -0
  54. package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
  55. package/lib/testing/index.cjs +74 -414
  56. package/lib/testing/index.cjs.map +1 -1
  57. package/lib/testing/index.d.cts +25 -385
  58. package/lib/testing/index.d.cts.map +1 -1
  59. package/lib/testing/index.d.mts +24 -385
  60. package/lib/testing/index.d.mts.map +1 -1
  61. package/lib/testing/index.mjs +72 -408
  62. package/lib/testing/index.mjs.map +1 -1
  63. package/lib/transport.cjs +36 -0
  64. package/lib/transport.d.cts +254 -0
  65. package/lib/transport.d.cts.map +1 -0
  66. package/lib/transport.d.mts +254 -0
  67. package/lib/transport.d.mts.map +1 -0
  68. package/lib/transport.mjs +6 -0
  69. package/package.json +37 -17
  70. package/docs/README.md +0 -316
  71. package/docs/adapters.md +0 -308
  72. package/docs/application-setup.md +0 -524
  73. package/docs/attributes.md +0 -689
  74. package/docs/controllers.md +0 -373
  75. package/docs/endpoints.md +0 -444
  76. package/docs/exceptions.md +0 -352
  77. package/docs/guards.md +0 -550
  78. package/docs/legacy-compat.md +0 -356
  79. package/docs/modules.md +0 -377
  80. package/docs/quick-start.md +0 -290
  81. package/docs/services.md +0 -427
  82. package/docs/testing.md +0 -827
  83. package/lib/index-3LcTrbxz.d.mts +0 -3804
  84. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  85. package/lib/index-B14SekVb.d.cts +0 -3804
  86. package/lib/index-B14SekVb.d.cts.map +0 -1
  87. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  88. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  89. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  90. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  91. package/lib/tokens-BEuBMGGX.cjs +0 -193
  92. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  93. package/lib/tokens-COyNGV1I.mjs +0 -97
  94. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  95. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  96. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  97. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  98. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  99. package/project.json +0 -66
  100. package/src/__tests__/attribute.factory.spec.mts +0 -300
  101. package/src/__tests__/config.service.spec.mts +0 -43
  102. package/src/__tests__/console-logger.service.spec.mts +0 -312
  103. package/src/__tests__/controller-resolver.spec.mts +0 -229
  104. package/src/__tests__/controller.spec.mts +0 -58
  105. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  106. package/src/__tests__/logger.service.spec.mts +0 -147
  107. package/src/__tests__/responders.spec.mts +0 -340
  108. package/src/__tests__/testing-module.spec.mts +0 -459
  109. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  110. package/src/attribute.factory.mts +0 -325
  111. package/src/config/config-service.interface.mts +0 -47
  112. package/src/config/config.provider.mts +0 -69
  113. package/src/config/config.service.mts +0 -176
  114. package/src/config/index.mts +0 -5
  115. package/src/config/types.mts +0 -58
  116. package/src/config/utils/helpers.mts +0 -23
  117. package/src/config/utils/index.mts +0 -1
  118. package/src/decorators/controller.decorator.mts +0 -81
  119. package/src/decorators/endpoint.decorator.mts +0 -181
  120. package/src/decorators/header.decorator.mts +0 -38
  121. package/src/decorators/http-code.decorator.mts +0 -38
  122. package/src/decorators/index.mts +0 -8
  123. package/src/decorators/module.decorator.mts +0 -106
  124. package/src/decorators/multipart.decorator.mts +0 -169
  125. package/src/decorators/stream.decorator.mts +0 -155
  126. package/src/decorators/use-guards.decorator.mts +0 -73
  127. package/src/exceptions/bad-request.exception.mts +0 -28
  128. package/src/exceptions/conflict.exception.mts +0 -31
  129. package/src/exceptions/forbidden.exception.mts +0 -30
  130. package/src/exceptions/http.exception.mts +0 -33
  131. package/src/exceptions/index.mts +0 -7
  132. package/src/exceptions/internal-server-error.exception.mts +0 -33
  133. package/src/exceptions/not-found.exception.mts +0 -33
  134. package/src/exceptions/unauthorized.exception.mts +0 -30
  135. package/src/factories/adapter.factory.mts +0 -20
  136. package/src/factories/endpoint-adapter.factory.mts +0 -21
  137. package/src/factories/http-adapter.factory.mts +0 -20
  138. package/src/factories/index.mts +0 -8
  139. package/src/factories/multipart-adapter.factory.mts +0 -21
  140. package/src/factories/reply.factory.mts +0 -21
  141. package/src/factories/request.factory.mts +0 -21
  142. package/src/factories/stream-adapter.factory.mts +0 -20
  143. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  144. package/src/index.mts +0 -16
  145. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  146. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  147. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  148. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  149. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  150. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  151. package/src/interfaces/adapter-environment.interface.mts +0 -74
  152. package/src/interfaces/can-activate.mts +0 -38
  153. package/src/interfaces/http-header.mts +0 -18
  154. package/src/interfaces/index.mts +0 -14
  155. package/src/interfaces/navios-module.mts +0 -28
  156. package/src/interfaces/plugin-context.mts +0 -104
  157. package/src/interfaces/plugin-stage.mts +0 -62
  158. package/src/interfaces/plugin.interface.mts +0 -119
  159. package/src/interfaces/staged-plugin.interface.mts +0 -209
  160. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  161. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  162. package/src/legacy-compat/attribute.factory.mts +0 -351
  163. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  164. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  165. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  166. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  167. package/src/legacy-compat/decorators/index.mts +0 -11
  168. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  169. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  170. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  171. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  172. package/src/legacy-compat/index.mts +0 -57
  173. package/src/logger/README.md +0 -3
  174. package/src/logger/console-logger.service.mts +0 -714
  175. package/src/logger/index.mts +0 -6
  176. package/src/logger/log-levels.mts +0 -21
  177. package/src/logger/logger-service.interface.mts +0 -42
  178. package/src/logger/logger.service.mts +0 -113
  179. package/src/logger/logger.tokens.mts +0 -44
  180. package/src/logger/utils/cli-colors.util.mts +0 -17
  181. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  182. package/src/logger/utils/index.mts +0 -5
  183. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  184. package/src/logger/utils/is-log-level.util.mts +0 -10
  185. package/src/logger/utils/shared.utils.mts +0 -51
  186. package/src/metadata/controller.metadata.mts +0 -79
  187. package/src/metadata/handler.metadata.mts +0 -80
  188. package/src/metadata/index.mts +0 -4
  189. package/src/metadata/module.metadata.mts +0 -116
  190. package/src/metadata/navios-managed.metadata.mts +0 -42
  191. package/src/navios.application.mts +0 -678
  192. package/src/navios.environment.mts +0 -42
  193. package/src/navios.factory.mts +0 -158
  194. package/src/responders/enums/framework-error.enum.mts +0 -38
  195. package/src/responders/enums/index.mts +0 -1
  196. package/src/responders/index.mts +0 -4
  197. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  198. package/src/responders/interfaces/error-response.interface.mts +0 -22
  199. package/src/responders/interfaces/index.mts +0 -3
  200. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  201. package/src/responders/services/error-response-producer.service.mts +0 -143
  202. package/src/responders/services/forbidden-responder.service.mts +0 -77
  203. package/src/responders/services/index.mts +0 -5
  204. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  205. package/src/responders/services/not-found-responder.service.mts +0 -76
  206. package/src/responders/services/validation-error-responder.service.mts +0 -78
  207. package/src/responders/tokens/index.mts +0 -1
  208. package/src/responders/tokens/responder.tokens.mts +0 -84
  209. package/src/services/abstract-handler-adapter.service.mts +0 -366
  210. package/src/services/guard-runner.service.mts +0 -152
  211. package/src/services/index.mts +0 -4
  212. package/src/services/instance-resolver.service.mts +0 -177
  213. package/src/services/module-loader.service.mts +0 -255
  214. package/src/stores/index.mts +0 -1
  215. package/src/stores/request-id.store.mts +0 -85
  216. package/src/testing/index.mts +0 -3
  217. package/src/testing/testing-module.mts +0 -393
  218. package/src/testing/unit-testing-module.mts +0 -298
  219. package/src/tokens/adapter.token.mts +0 -6
  220. package/src/tokens/endpoint-adapter.token.mts +0 -8
  221. package/src/tokens/execution-context.token.mts +0 -9
  222. package/src/tokens/http-adapter.token.mts +0 -8
  223. package/src/tokens/index.mts +0 -10
  224. package/src/tokens/multipart-adapter.token.mts +0 -8
  225. package/src/tokens/navios-options.token.mts +0 -6
  226. package/src/tokens/reply.token.mts +0 -3
  227. package/src/tokens/request.token.mts +0 -3
  228. package/src/tokens/stream-adapter.token.mts +0 -8
  229. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  230. package/src/utils/adapter-supports.util.mts +0 -47
  231. package/src/utils/define-plugin.mts +0 -251
  232. package/src/utils/index.mts +0 -2
  233. package/tsconfig.json +0 -21
  234. package/tsconfig.lib.json +0 -8
  235. package/tsconfig.spec.json +0 -15
  236. package/tsdown.config.mts +0 -35
  237. package/vitest.config.mts +0 -15
package/CHANGELOG.md CHANGED
@@ -5,6 +5,89 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.0-alpha.1] - Unreleased
9
+
10
+ ### Breaking
11
+
12
+ - **`@navios/core/transport` exports less.** A transport that imports these from it changes the import:
13
+ - `hasModuleMetadata` is removed; `getModuleMetadata` throws for a class that is not a module.
14
+ - The types that `@navios/core` exports are no longer exported a second time: `Transport`, `TransportFactory`, `TransportInstance`, `Guard`, `GuardClass`, `Interceptor`, `InterceptorClass`, `ExecutionContext`, `HandlerInfo`, `AttributeMap`, `ClassType` and `LoggerService`. Import them from `@navios/core`. `TransportDefinition` and `TransportHost` stay.
15
+ - **`RegisterProviderOptions` is no longer exported**, as `@navios/di` no longer has the type.
16
+ - **`isLogLevel` is removed** from `@navios/core`. `filterLogLevels` reads levels from a setting, and throws for one that does not exist.
17
+ - **`BasicExecutionContextInit` has no `signal`**, which no transport passed: the signal of a `BasicExecutionContext` is its own and never aborts.
18
+ - **`HandlerInfo.module` is a `ClassType`**, no longer `| null`: every transport sets it.
19
+ - **`ConsoleLogger`'s protected `printMessages()` takes no `requestId`**, which nothing passed: the id is that of `currentContext()` when the `requestId` option is on. `getRequestId()` and `printAsJson()`, protected as well, print the id they are given without checking the option again.
20
+ - **`handlerChain` builds the `HandlerInfo`.** It takes the `controller` and the `handlerName` of the handler besides `node`, `owner` and `member`, and returns `{ info, outer, inner }`: `info` is what the handler's contexts carry as `ctx.handler`, its guards in `info.guards`. `HandlerChain.guards` and `HandlerChain.interceptors` are removed. `resolveChain` takes what `handlerChain` returns, the guards in `info.guards`.
21
+ - **`ContextHost.onScopedUse` is called only for a token that `needsScope` is true for**, and no longer checks that itself. A context of a transport's own calls `needsScope` first, as `BasicExecutionContext` does; with the `'warn'` and `'forbid'` policies a context looks up the provider of a token once per resolution instead of twice.
22
+
23
+ ### Added
24
+
25
+ - **`executeChain(host, ctx, chain, handler, onDenied)`** in `@navios/core/transport`: `runChain` with a context of the transport's own, in the async context when `host.asyncContext` is set, and `ctx.finish()` afterwards, whatever the outcome.
26
+ - **`moduleClasses(node, entry)`** in `@navios/core/transport`: the classes a module lists under an option of a transport, once each. Something that is not a class fails with the module and the option, as an import cycle between files leaves `undefined` behind.
27
+ - **`classMetadata(key, what, decorator)`** in `@navios/core/transport`: `define`, `get` and `has` for what a class decorator stores on a class. Only the class itself carries it, not a subclass, and `get` throws `Users is not a controller. Make sure it is decorated with @Controller.` for a class without it.
28
+ - **`ownMetadata(metadata, key, create)` and `requireMetadata(context)`** in `@navios/core/transport`, for decorators that keep their own entries in decorator metadata: the entry of this class, created from what its parent has, and the metadata of a context that has to have one.
29
+ - **`disposeScope(scope)`** in `@navios/core/transport`, re-exported from `@navios/di/internal` as `constructedInstances` is: a transport ends the scope of a context of its own without depending on `@navios/di`.
30
+ - **`settledWithin(work, ms)` and `MAX_DELAY_MS`** in `@navios/core/transport`: whether a promise settles within `ms`, for a transport's `stop(timeoutMs)`. A longer time than a timer takes is cut to `MAX_DELAY_MS`.
31
+
32
+ ### Fixed
33
+
34
+ - **An application starts in `workerd`**, the runtime of Cloudflare Workers. `AsyncLocalStorage.disable()` throws there, which failed every lifecycle step, and the logger imported `util` without the `node:` prefix, which a Worker's bundle does not resolve.
35
+ - **A Worker with a compatibility date before 2025-09-15 starts.** Importing `@navios/core` needed `node:os`, which `workerd` has from that date only, so the Worker failed at start-up with `No such module "node:os"`; the module is now asked for when a signal ends process 1, and the exit code is the same. The logger called `process.on()`, which the `process` of an earlier date does not have, so every request was a 500; it waits for the exit of the process only where there is one.
36
+ - **A schema that answers with a thenable that is not a native promise**, such as a promise of another realm, is refused by `AttributeFactory.createAttribute` and `provideConfig` as one that answers with a promise is. It was taken for a result without issues, so the value was `undefined`.
37
+
38
+ ## [2.0.0-alpha.0] - 2026-11-26
39
+
40
+ `@navios/core` is now the part of Navios that does not depend on HTTP. The HTTP framework it was in 1.x is `@navios/server`, which is built on this package and re-exports it. The changes to the HTTP framework itself are listed in the changelog of `@navios/server`.
41
+
42
+ ### Breaking
43
+
44
+ - **The HTTP framework moved to `@navios/server`.** Controllers, `@Endpoint`, `handler()`, `RequestContext`, `HttpException` and the other errors, `reply()`, `NaviosFactory`, `NaviosApplication`, the adapter contract, SSE and request values are exported from `@navios/server`. An HTTP application replaces the import specifier `@navios/core` with `@navios/server`, including `@navios/core/testing`, `@navios/core/legacy-compat` and the `declare module` of `Register`.
45
+ - **`@navios/core/conformance` moved** to `@navios/server/conformance`.
46
+ - **`@navios/builder` is no longer a peer dependency.**
47
+ - **`Guard` and `Interceptor` are generic.** `Guard<Ctx>` and `Interceptor<Ctx, Result>` default to `ExecutionContext`, the context every transport provides. `@navios/server` exports the HTTP-typed versions under the same names.
48
+ - **`currentContext()` returns an `ExecutionContext`.** The one from `@navios/server` returns the `RequestContext`.
49
+ - **`@Module` knows `imports`, `providers`, `guards`, `interceptors` and `attributes`.** `prefix`, `controllers` and `requestValues` are added by `@navios/server`. `ModuleMetadata` keeps options of transports in `entries`.
50
+ - **`buildModuleGraph(roots)` takes no prefix** and returns nodes with `entries`, `importers`, `isRoot` and `disputed` in place of `prefix`, `controllers` and `requestValues`. It is exported from `@navios/core/transport`.
51
+ - **The plugin API has no HTTP members.** `adapter`, `encoder` and `mapError` are on the HTTP transport, `api.transport(httpTransport)`, and `onBootstrap` hooks receive no arguments.
52
+ - **`@navios/di` 2.0** has its own breaking changes: registries and priorities are removed, a singleton cannot depend on a request-scoped service, `container.beginRequest()` is `container.createScope()`. What applications use of it is re-exported by name.
53
+ - **Guards run before the interceptors of the module, the class and the handler.** Interceptors of the application stay outside the guards. `handlerChain` returns the two groups as `outer` and `inner`. Only `true` from a guard lets the handler run.
54
+ - **`provideConfig` returns an `InjectionToken<ConfigService<…>>`**, which can be replaced like any other token. `load` runs once per container, and at once when it is synchronous. `ConfigService` logs nothing and can be created with `new`. `ConfigServiceToken`, `ConfigServiceOptions`, `ConfigServiceOptionsSchema`, `PathImpl` and `PathImpl2` are removed. `get()` is never typed `undefined`, and `getOrThrow()` and `getOrDefault()` neither `undefined` nor `null`.
55
+ - **`envInt`** throws for a variable that is not an integer. It used to take `12abc` for 12 and to return `NaN` for `abc`.
56
+ - **The provider of a token is chosen by who provides it**: the application's container and options, plugins, modules, the default. A module wins over what it imports, and a module of the application over one that a plugin adds; two modules that provide different things for a token without one importing the other are an error where one of them would be used, and so is a provider that comes after its token was resolved. `providers` takes what `provide()` returns and refuses anything else.
57
+ - **Modules cannot import each other in a cycle**, and a class can be made a module once.
58
+ - **An application that fails to initialise or to start is closed**, its container included.
59
+ - **`enableShutdownHooks()` ends the process**: when everything the signal closes is closed, the process gets the signal again, or exits with its code when it is process 1. `{ exit: false }` turns that off. A signal during a `close()` waits for it.
60
+ - **The console logger** prints `log` and above when `NODE_ENV` is `production` and uses colours when stdout is a terminal. `setup()` changes the options it is given. With `json`, an error is an `error` object on the line of its message, with its own fields and the errors it holds. `filterLogLevels` throws for a level that does not exist; `isLogLevelEnabled` and `loggerOptionsSchema` are no longer exported.
61
+ - **`Logger` is transient**: every injection has its own instance.
62
+ - **`getModuleMetadata` and `hasModuleMetadata`** are exported from `@navios/core/transport`; `ModuleMetadataKey` is not exported.
63
+
64
+ ### Added
65
+
66
+ - **`createApplication(AppModule, options)`** and `Application`: an application that hosts zero or more transports sharing one module graph, container, plugin set and lifecycle. `init()`, `start()`, `close()`, `transport(factory)`.
67
+ - **Transports.** `defineTransport` in `@navios/core/transport`, with the module graph, `describeHandlerClass`, `handlerChain`, `resolveChain`, `runChain` and `BasicExecutionContext` for transport authors.
68
+ - **`shutdownTimeout`** bounds every step of `close()`, each hook on its own. A step that takes longer is logged and left behind.
69
+ - **A plugin can provide the logger**, as can a module it adds. What is logged before all plugins are set up is written then.
70
+ - **`ExecutionContext`**, `HandlerInfo` and `ExecutionContextToken`: what a guard, an interceptor or a request-scoped service can rely on with any transport.
71
+ - **Open `@Module` options.** A transport package adds its own option by declaration merging. An option that no transport of the running application reads is ignored, so one module can serve several transports.
72
+ - **`@navios/core/testing`** with `fakeTransport`.
73
+ - **A warning when two copies of the package are loaded.**
74
+
75
+ ### Fixed
76
+
77
+ - **`close()` called again while a shutdown is in flight** returns that shutdown instead of resolving at once. From something the shutdown waits for it resolves at once; from something `init()` or `start()` waits for it rejects, instead of waiting for itself, and closes afterwards. `start()` called from something `init()` waits for does the same.
78
+ - **Hooks run in dependency order**: `onApplicationBootstrap` for dependencies first, `onApplicationShutdown` for dependents first, once per object, and only for objects the container built that declare them.
79
+ - **What a destroy hook throws** goes to the application's logger.
80
+ - **A subclass inherits what decorators attached to its base class**, guards and endpoints included, with the decorators of `@navios/core/legacy-compat` as well, and from a module that `registerModule` made one.
81
+ - **A configuration that fails validation** is reported with the paths of what is wrong and without its values.
82
+ - **The console logger** prints an error that is passed without a context, and neither throws for what it is given nor prints nothing when it is created with `new`.
83
+ - **A `close()` that rejects after a signal** from `enableShutdownHooks()` is reported through the logger instead of becoming an unhandled rejection.
84
+ - **`providers` of a module are applied before anything is resolved**, so `@Module({ providers: [provide(LoggerOutput, …)] })` takes effect. Providers of modules that a plugin adds are applied after the plugins are set up.
85
+ - **`buildModuleGraph` visits a module once** however many paths reach it; diamond imports used to cost exponential time. Inherited guards and interceptors now always come before the module's own, and what a shared module inherits no longer depends on the path that reached it first. Import paths that give it different values of an attribute are an error where a handler would inherit the attribute.
86
+ - **An `undefined` entry in `imports`**, the usual sign of an import cycle between files, throws an error that names the importing module.
87
+ - **A plugin registered twice with different options**, and two plugins of one name, throw instead of dropping the second registration.
88
+ - **The second-copy warning** also covers copies loaded only through `@navios/core/transport`, `/testing` or `/legacy-compat`.
89
+ - **An `onFinish` callback that throws** is reported to the application's logger; it used to be dropped silently.
90
+
8
91
  ## [1.1.0] - 2026-01-15
9
92
 
10
93
  ### Added
@@ -171,7 +254,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
171
254
 
172
255
  - Updated to support `@navios/builder` ^1.0.0-alpha.2 with new `RequestArgs` type system
173
256
 
174
- ## [1.0.0-alpha.1] - 2026-01-22
257
+ ## [1.0.0-alpha.1] - 2026-01-07
175
258
 
176
259
  ### Added
177
260
 
@@ -309,7 +392,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
309
392
  - Guards can be pre-resolved at startup for faster request handling
310
393
  - Response validation can be disabled for production performance
311
394
 
312
- ## [0.7.1] - 2025-12-18
395
+ ## [0.7.1] - 2025-12-20
313
396
 
314
397
  ### Added
315
398
 
@@ -406,14 +489,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
406
489
  - `@navios/di` - Dependency injection container
407
490
  - `@navios/builder` (peer dependency) - Type-safe API definitions
408
491
  - `zod` (peer dependency) - Schema validation
409
-
410
- ---
411
-
412
- ## [Unreleased]
413
-
414
- ### Planned
415
-
416
- - Additional adapter implementations
417
- - Enhanced middleware support
418
- - WebSocket support
419
- - Performance optimizations
package/README.md CHANGED
@@ -1,261 +1,110 @@
1
- # Navios
1
+ # @navios/core
2
2
 
3
- Navios is a Type-Safe HTTP Server with Zod Validation.
3
+ What a Navios application is made of, whatever reaches it: dependency injection, modules, plugins, lifecycle hooks, configuration and logging, and the contracts a transport builds on. It has no HTTP in it.
4
4
 
5
- It is a powerful tool for building robust and type-safe APIs using TypeScript. It leverages the power of Zod for validation and provides a simple and intuitive API for defining endpoints, request and response schemas, and handling errors.
5
+ - An HTTP server is [`@navios/server`](https://www.npmjs.com/package/@navios/server), which is built on this package and re-exports it. Install that one for a web application.
6
+ - This package alone runs a worker: a process that consumes a queue, runs scheduled jobs, or both.
6
7
 
7
- Navios is adapter-based, allowing you to choose the underlying HTTP server implementation. Currently supported adapters include:
8
+ **[Documentation](https://navios.tech/docs/server/guides/other-transports)**
8
9
 
9
- - **Fastify** (via `@navios/adapter-fastify`) - A fast and low-overhead web framework for Node.js
10
- - **Bun** (via `@navios/adapter-bun`) - A fast JavaScript runtime optimized for server-side applications
11
-
12
- ## Prerequisites
13
-
14
- To work as an HTTP server, you must install one of the supported adapters:
10
+ ## Install
15
11
 
16
12
  ```bash
17
- # For Fastify adapter
18
- npm install @navios/adapter-fastify
19
-
20
- # OR for Bun adapter
21
- npm install @navios/adapter-bun
13
+ npm install @navios/core@next
22
14
  ```
23
15
 
24
- The adapter must be provided when creating your Navios application to define the underlying HTTP server implementation.
25
-
26
- ## Features
16
+ The 2.0 alpha is published under the `next` tag. All `@navios` packages of a project must have the same alpha version, because an alpha may break between releases.
27
17
 
28
- - **Type Safety**: Navios provides a type-safe API for defining endpoints, request and response schemas. This ensures that your API is always type-safe and reduces the risk of runtime errors.
29
- - **Validation**: Zod provides powerful validation capabilities, allowing you to define complex validation rules for your data. This ensures that the data you work with is always valid and meets your requirements.
30
- - **Build with Navios Builder**: Navios Builder is a powerful HTTP client that simplifies API requests. By combining it with Navios, you can use the same API definition for both the client and server, ensuring consistency and reducing duplication.
31
- - **Declarative API**: The API is designed to be declarative, allowing you to define your API endpoints and their schemas in a clear and concise manner. This makes it easy to understand and maintain your API client.
32
- - **Customizable**: The package allows you to customize the behavior of the API client, such as using a custom client.
33
- - **Error Handling**: The package provides built-in error handling capabilities with RFC 7807 Problem Details format for standardized error responses. Includes customizable error responders and comprehensive exception handling.
18
+ Navios uses standard (TC39) decorators, so leave `experimentalDecorators` off. A project that has to keep it on imports from `@navios/core/legacy-compat`.
34
19
 
35
- ## Adapters
20
+ ## Example
36
21
 
37
- Navios uses an adapter pattern to support different HTTP server implementations. Each adapter provides the necessary bindings to integrate with a specific runtime or framework.
38
-
39
- ### Available Adapters
40
-
41
- #### Fastify Adapter (`@navios/adapter-fastify`)
42
-
43
- - Built on top of [Fastify](https://www.fastify.io/), a fast and low-overhead web framework
44
- - Excellent performance and a rich ecosystem of plugins
45
- - Full Node.js compatibility
46
- - Supports all Fastify features including hooks, plugins, and decorators
22
+ A worker that runs scheduled jobs, with [`@navios/schedule`](https://www.npmjs.com/package/@navios/schedule):
47
23
 
48
24
  ```ts
49
- import { defineFastifyEnvironment } from '@navios/adapter-fastify'
25
+ import { createApplication, inject, Injectable, Logger, Module } from '@navios/core'
26
+ import { Cron, Schedulable, Schedule, scheduleTransport } from '@navios/schedule'
50
27
 
51
- const app = await NaviosFactory.create(AppModule, {
52
- adapter: defineFastifyEnvironment(),
53
- })
54
- ```
28
+ @Injectable()
29
+ class SessionsService {
30
+ async deleteExpired() {
31
+ return 0
32
+ }
33
+ }
55
34
 
56
- #### Bun Adapter (`@navios/adapter-bun`)
35
+ @Schedulable()
36
+ class MaintenanceJobs {
37
+ private readonly sessions = inject(SessionsService)
38
+ private readonly logger = inject(Logger, { context: 'MaintenanceJobs' })
57
39
 
58
- - Built for [Bun](https://bun.sh/), a fast JavaScript runtime optimized for performance
59
- - Native HTTP server implementation with excellent performance
60
- - Optimized for Bun's runtime features
61
- - Lightweight and efficient
40
+ @Cron(Schedule.EveryHour)
41
+ async purgeSessions() {
42
+ this.logger.log(`Removed ${await this.sessions.deleteExpired()} expired sessions`)
43
+ }
44
+ }
62
45
 
63
- ```ts
64
- import { defineBunEnvironment } from '@navios/adapter-bun'
46
+ @Module({ jobs: [MaintenanceJobs] })
47
+ class WorkerModule {}
65
48
 
66
- const app = await NaviosFactory.create(AppModule, {
67
- adapter: defineBunEnvironment(),
49
+ const app = createApplication(WorkerModule, {
50
+ transports: [scheduleTransport()],
68
51
  })
69
- ```
52
+ app.enableShutdownHooks()
70
53
 
71
- ### Choosing an Adapter
72
-
73
- The choice of adapter depends on your deployment environment and performance requirements:
74
-
75
- - Use **Fastify adapter** if you need Node.js compatibility, access to the Fastify ecosystem, or are deploying to traditional Node.js environments
76
- - Use **Bun adapter** if you're running on Bun runtime and want to take advantage of its performance optimizations
77
-
78
- ## Main Concepts
79
-
80
- - **Module**: A module is a collection of controllers, and other modules. It is used to group related functionality together and provide a clear structure for your API. It also can define some shared guards, attributes, and service overrides.
81
- - **Controller**: A controller is a class that defines a set of endpoints for a specific resource. It is used to handle incoming requests and return responses. Controllers can also define guards and attributes that apply to all endpoints in the controller.
82
- - **Endpoint**: An endpoint is a specific route in your API that handles a specific request. It used original endpoint definition from Navios Builder, and a set of request and response schemas. Endpoints can also define guards and attributes that apply to the endpoint.
83
- - **Service**: A service is a class that defines the business logic for a specific resource. It is used to separate the business logic from the controller and provide a clear structure for your API.
84
- - **Guard**: A guard is a class that is used to validate incoming requests and ensure that they meet certain criteria. Guards can be used to validate request parameters, headers, and body. They can also be used to check authentication and authorization.
85
- - **Attribute**: An attribute is a decorator that is used to add metadata to a class or method. Attributes can be used in guards, controllers, modules, and endpoints to provide additional information about the class or method.
86
-
87
- ## Legacy-Compatible Decorators
88
-
89
- Navios provides legacy-compatible decorators for projects that use TypeScript's experimental decorator API. These decorators are available from `@navios/core/legacy-compat` and provide the same functionality as the standard decorators, but with compatibility for projects that cannot use Stage 3 decorators.
90
-
91
- ```ts
92
- import { Controller, Endpoint, Module } from '@navios/core/legacy-compat'
93
-
94
- @Module({
95
- controllers: [UserController],
96
- })
97
- export class AppModule {}
54
+ await app.start()
98
55
  ```
99
56
 
100
- For more information, see the [Legacy-Compatible Decorators documentation](./docs/legacy-compat.md).
101
-
102
- ## Getting Started
103
-
104
- ### Define your API
57
+ ## Transports
105
58
 
106
- Define your API in a shared location accessible to both the client and server. This allows you to use the same API definition for both the client and server, ensuring consistency and reducing duplication.
59
+ An application hosts zero or more transports: the ways work reaches it. They share its modules, its container, its plugins and its lifecycle.
107
60
 
108
61
  ```ts
109
- import { builder } from '@navios/builder'
110
-
111
- import { z } from 'zod/v4'
112
-
113
- const api = builder({
114
- useDiscriminatorResponse: true,
115
- })
116
-
117
- const login = api.declareEndpoint({
118
- method: 'post',
119
- url: '/login',
120
- requestSchema: z.object({
121
- email: z.string().email(),
122
- password: z.string().min(6),
123
- }),
124
- responseSchema: z.discriminatedUnion('success', [
125
- z.object({
126
- success: z.literal(true),
127
- user: z.object({
128
- id: z.string(),
129
- name: z.string(),
130
- email: z.string().email(),
131
- }),
132
- }),
133
- z.object({
134
- success: z.literal(false),
135
- error: z.string(),
136
- }),
137
- ]),
62
+ const app = createApplication(AppModule, {
63
+ transports: [messageTransport()], // from @navios/microservice
138
64
  })
139
65
  ```
140
66
 
141
- ### Create your server
67
+ `@navios/microservice` is not published yet.
142
68
 
143
- ```bash
144
- # Install core dependencies
145
- yarn install --save @navios/core @navios/builder zod
146
-
147
- # Install one of the supported adapters
148
- yarn install --save @navios/adapter-fastify
149
- # OR
150
- yarn install --save @navios/adapter-bun
151
- ```
152
-
153
- Create AuthService:
154
-
155
- ```ts
156
- import { Injectable } from '@navios/core'
157
-
158
- @Injectable()
159
- export class LoginService {
160
- async login(email: string, password: string) {
161
- // Perform your login logic here
162
- // For example, check the email and password against a database
163
- }
164
- }
165
- ```
166
-
167
- Create your first Controller:
168
-
169
- ```ts
170
- import type { EndpointParams } from '@navios/core'
171
-
172
- import { Controller, Endpoint, inject } from '@navios/core'
173
-
174
- import { AuthService } from './auth.service.mjs'
69
+ | Transport | Package | `@Module` option |
70
+ | --------- | -------------------------------------------------------------------- | -------------------- |
71
+ | HTTP | [`@navios/server`](https://www.npmjs.com/package/@navios/server) | `controllers` |
72
+ | Messages | `@navios/microservice` (not published yet) | `messageControllers` |
73
+ | Cron jobs | [`@navios/schedule`](https://www.npmjs.com/package/@navios/schedule) | `jobs` |
175
74
 
176
- @Controller()
177
- export class AuthController {
178
- // Inject the LoginService
179
- loginService = inject(LoginService)
75
+ A module lists what it has for each transport, and an application ignores the options of transports it does not have, so one module can serve several.
180
76
 
181
- @Endpoint(login)
182
- async login(request: EndpointParams<typeof login>) {
183
- // Handle the login request
184
- const { email, password } = request
77
+ ## What it contains
185
78
 
186
- // Perform your login logic here
187
- const user = await this.loginService.login(email, password)
79
+ | Need | How |
80
+ | ----------------------------------------- | ---------------------------------------------------------------------------- |
81
+ | Services and their scopes | `@Injectable()`, `inject()`, `provide()` and the rest of `@navios/di` |
82
+ | Grouping, shared guards and attributes | `@Module()` |
83
+ | The application and its lifecycle | `createApplication`, `init()`, `start()`, `close()` |
84
+ | Hooks | `onModuleInit`, `onApplicationBootstrap`, `onApplicationShutdown` |
85
+ | Reusable setup | `definePlugin` |
86
+ | Guards and interceptors for any transport | `Guard`, `Interceptor`, `ExecutionContext`, `@UseGuards`, `@UseInterceptors` |
87
+ | Per-execution data | `createContextKey`, `currentContext()` |
88
+ | Metadata on modules and handlers | `AttributeFactory` |
89
+ | Typed configuration, logging | `provideConfig`, `Logger` |
188
90
 
189
- if (user) {
190
- return { success: true, user }
191
- } else {
192
- return { success: false, error: 'Invalid credentials' }
193
- }
194
- }
195
- }
196
- ```
197
-
198
- Create your AppModule:
199
-
200
- ```ts
201
- import { Module } from '@navios/core'
202
-
203
- import { AuthController } from './auth.controller.mjs'
204
-
205
- @Module({
206
- controllers: [AuthController],
207
- // Optional: overrides for service implementations with higher priority
208
- // overrides: [OverrideService],
209
- })
210
- export class AppModule {}
211
- ```
212
-
213
- Create your server:
214
-
215
- ```ts
216
- // Import your chosen adapter
217
- import { defineFastifyEnvironment } from '@navios/adapter-fastify'
218
- import { NaviosFactory } from '@navios/core'
219
-
220
- // OR import { defineBunEnvironment } from '@navios/adapter-bun'
221
-
222
- import { AppModule } from './src/app.module.mjs'
223
-
224
- export async function boot() {
225
- const app = await NaviosFactory.create(AppModule, {
226
- // Provide the adapter environment
227
- adapter: defineFastifyEnvironment(),
228
- // OR adapter: defineBunEnvironment(),
229
- })
230
- app.setGlobalPrefix('/api')
231
- app.enableCors({
232
- methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
233
- })
234
- await app.init()
235
- await app.listen({ port: 3000, host: '0.0.0.0' })
236
- }
237
- await boot()
238
- ```
91
+ ## Entry points
239
92
 
240
- That's it! You have created your first Navios server. You can now run your server and test the `/api/login` endpoint.
93
+ | Import | Contents |
94
+ | ---------------------------- | ----------------------------------------------------------------------------------------------- |
95
+ | `@navios/core` | The above, with what applications use of `@navios/di`. |
96
+ | `@navios/core/transport` | For transport authors: the contract, the module graph, handler chains, `BasicExecutionContext`. |
97
+ | `@navios/core/testing` | `fakeTransport`, a transport for tests of plugins and of the application lifecycle. |
98
+ | `@navios/core/legacy-compat` | Decorators for `experimentalDecorators` projects. |
241
99
 
242
- ## Documentation
100
+ ## One copy
243
101
 
244
- - **[Quick Start Guide](./docs/quick-start.md)** - Get up and running quickly
245
- - **[Complete Documentation](./docs/README.md)** - Comprehensive framework documentation
246
- - **[Adapter Guide](./docs/adapters.md)** - Detailed adapter information and comparison
247
- - **[Legacy-Compatible Decorators](./docs/legacy-compat.md)** - Using Navios with TypeScript experimental decorators
248
- - **[API Examples](https://github.com/Arilas/navios/tree/main/examples)** - Working code examples
249
- - **[CHANGELOG](./CHANGELOG.md)** - Version history and release notes
102
+ Every package of an application has to resolve the same `@navios/core`. `@navios/server`, the other transports and the plugins that work on any transport list it as a peer dependency, so an application installs it once, beside them. HTTP adapters peer on `@navios/server` only and reach this package through it. If two copies are loaded, a warning names both locations. Two copies that a bundler put into one file are not noticed.
250
103
 
251
- ## Related Packages
104
+ ## Upgrading from 1.x
252
105
 
253
- - **[@navios/adapter-fastify](https://www.npmjs.com/package/@navios/adapter-fastify)** - Fastify HTTP adapter
254
- - **[@navios/adapter-bun](https://www.npmjs.com/package/@navios/adapter-bun)** - Bun HTTP adapter
255
- - **[@navios/builder](https://www.npmjs.com/package/@navios/builder)** - Type-safe API definitions
256
- - **[@navios/di](https://www.npmjs.com/package/@navios/di)** - Dependency injection container
257
- - **[@navios/jwt](https://www.npmjs.com/package/@navios/jwt)** - JWT authentication utilities
106
+ In 1.x this package was the HTTP framework. That is now `@navios/server`: replace the import specifier `@navios/core` with `@navios/server`, and see [Migrating to 2.0](https://navios.tech/docs/server/reference/migrating-to-2). [CHANGELOG.md](./CHANGELOG.md) has the full list.
258
107
 
259
108
  ## License
260
109
 
261
- MIT
110
+ MIT. The console logger is ported from [NestJS](https://github.com/nestjs/nest) (MIT). Big thanks to the NestJS team for their work.