@forinda/kickjs 2.0.1 → 2.2.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.
Files changed (238) hide show
  1. package/README.md +63 -20
  2. package/dist/adapter-wuoBNkNs.d.mts +122 -0
  3. package/dist/adapter-wuoBNkNs.d.mts.map +1 -0
  4. package/dist/app-module-DOBmxARW.d.mts +40 -0
  5. package/dist/app-module-DOBmxARW.d.mts.map +1 -0
  6. package/dist/application-C5Q720a2.mjs +449 -0
  7. package/dist/application-C5Q720a2.mjs.map +1 -0
  8. package/dist/bootstrap-dEN6SjBl.mjs +205 -0
  9. package/dist/bootstrap-dEN6SjBl.mjs.map +1 -0
  10. package/dist/{core/cache.d.ts → cache-PufEhr0n.d.mts} +33 -31
  11. package/dist/cache-PufEhr0n.d.mts.map +1 -0
  12. package/dist/chunk-C9tIbwLT.mjs +15 -0
  13. package/dist/container-B7jFEbPE.mjs +496 -0
  14. package/dist/container-B7jFEbPE.mjs.map +1 -0
  15. package/dist/container-CcgV8eHL.d.mts +253 -0
  16. package/dist/container-CcgV8eHL.d.mts.map +1 -0
  17. package/dist/core/adapter.d.mts +3 -0
  18. package/dist/core/adapter.mjs +11 -0
  19. package/dist/core/app-module.d.mts +3 -0
  20. package/dist/core/app-module.mjs +11 -0
  21. package/dist/core/cache.d.mts +3 -0
  22. package/dist/core/cache.mjs +113 -0
  23. package/dist/core/cache.mjs.map +1 -0
  24. package/dist/core/container.d.mts +3 -0
  25. package/dist/core/container.mjs +12 -0
  26. package/dist/core/cron.d.mts +3 -0
  27. package/dist/core/cron.mjs +42 -0
  28. package/dist/core/cron.mjs.map +1 -0
  29. package/dist/core/decorators.d.mts +3 -0
  30. package/dist/core/decorators.mjs +219 -0
  31. package/dist/core/decorators.mjs.map +1 -0
  32. package/dist/core/errors.d.mts +3 -0
  33. package/dist/core/errors.mjs +97 -0
  34. package/dist/core/errors.mjs.map +1 -0
  35. package/dist/core/interfaces.d.mts +3 -0
  36. package/dist/core/interfaces.mjs +44 -0
  37. package/dist/core/interfaces.mjs.map +1 -0
  38. package/dist/core/logger.d.mts +3 -0
  39. package/dist/core/logger.mjs +217 -0
  40. package/dist/core/logger.mjs.map +1 -0
  41. package/dist/core/path.d.mts +3 -0
  42. package/dist/core/path.mjs +45 -0
  43. package/dist/core/path.mjs.map +1 -0
  44. package/dist/core/plugin.d.mts +3 -0
  45. package/dist/core/plugin.mjs +11 -0
  46. package/dist/core/reactivity.d.mts +3 -0
  47. package/dist/core/reactivity.mjs +189 -0
  48. package/dist/core/reactivity.mjs.map +1 -0
  49. package/dist/core-CMgIoRvg.mjs +121 -0
  50. package/dist/core-CMgIoRvg.mjs.map +1 -0
  51. package/dist/{core/cron.d.ts → cron-C29iHvHT.d.mts} +16 -14
  52. package/dist/cron-C29iHvHT.d.mts.map +1 -0
  53. package/dist/decorators-D3lBlmud.d.mts +204 -0
  54. package/dist/decorators-D3lBlmud.d.mts.map +1 -0
  55. package/dist/errors-BZUdxtjC.d.mts +68 -0
  56. package/dist/errors-BZUdxtjC.d.mts.map +1 -0
  57. package/dist/http/application.d.mts +220 -0
  58. package/dist/http/application.d.mts.map +1 -0
  59. package/dist/http/application.mjs +12 -0
  60. package/dist/http/bootstrap.d.mts +43 -0
  61. package/dist/http/bootstrap.d.mts.map +1 -0
  62. package/dist/http/bootstrap.mjs +12 -0
  63. package/dist/http/context.d.mts +190 -0
  64. package/dist/http/context.d.mts.map +1 -0
  65. package/dist/http/context.mjs +225 -0
  66. package/dist/http/context.mjs.map +1 -0
  67. package/dist/http/middleware/cors.d.mts +48 -0
  68. package/dist/http/middleware/cors.d.mts.map +1 -0
  69. package/dist/http/middleware/cors.mjs +83 -0
  70. package/dist/http/middleware/cors.mjs.map +1 -0
  71. package/dist/http/middleware/csrf.d.mts +52 -0
  72. package/dist/http/middleware/csrf.d.mts.map +1 -0
  73. package/dist/http/middleware/csrf.mjs +72 -0
  74. package/dist/http/middleware/csrf.mjs.map +1 -0
  75. package/dist/http/middleware/error-handler.d.mts +11 -0
  76. package/dist/http/middleware/error-handler.d.mts.map +1 -0
  77. package/dist/http/middleware/error-handler.mjs +52 -0
  78. package/dist/http/middleware/error-handler.mjs.map +1 -0
  79. package/dist/http/middleware/helmet.d.mts +41 -0
  80. package/dist/http/middleware/helmet.d.mts.map +1 -0
  81. package/dist/http/middleware/helmet.mjs +51 -0
  82. package/dist/http/middleware/helmet.mjs.map +1 -0
  83. package/dist/http/middleware/rate-limit.d.mts +56 -0
  84. package/dist/http/middleware/rate-limit.d.mts.map +1 -0
  85. package/dist/http/middleware/rate-limit.mjs +101 -0
  86. package/dist/http/middleware/rate-limit.mjs.map +1 -0
  87. package/dist/http/middleware/request-id.d.mts +10 -0
  88. package/dist/http/middleware/request-id.d.mts.map +1 -0
  89. package/dist/http/middleware/request-id.mjs +26 -0
  90. package/dist/http/middleware/request-id.mjs.map +1 -0
  91. package/dist/http/middleware/request-logger.d.mts +32 -0
  92. package/dist/http/middleware/request-logger.d.mts.map +1 -0
  93. package/dist/http/middleware/request-logger.mjs +49 -0
  94. package/dist/http/middleware/request-logger.mjs.map +1 -0
  95. package/dist/http/middleware/session.d.mts +67 -0
  96. package/dist/http/middleware/session.d.mts.map +1 -0
  97. package/dist/http/middleware/session.mjs +152 -0
  98. package/dist/http/middleware/session.mjs.map +1 -0
  99. package/dist/http/middleware/spa.d.mts +101 -0
  100. package/dist/http/middleware/spa.d.mts.map +1 -0
  101. package/dist/http/middleware/spa.mjs +108 -0
  102. package/dist/http/middleware/spa.mjs.map +1 -0
  103. package/dist/http/middleware/{upload.d.ts → upload.d.mts} +21 -17
  104. package/dist/http/middleware/upload.d.mts.map +1 -0
  105. package/dist/http/middleware/upload.mjs +191 -0
  106. package/dist/http/middleware/upload.mjs.map +1 -0
  107. package/dist/http/middleware/validate.d.mts +18 -0
  108. package/dist/http/middleware/validate.d.mts.map +1 -0
  109. package/dist/http/middleware/validate.mjs +62 -0
  110. package/dist/http/middleware/validate.mjs.map +1 -0
  111. package/dist/http/middleware/views.d.mts +62 -0
  112. package/dist/http/middleware/views.d.mts.map +1 -0
  113. package/dist/http/middleware/views.mjs +65 -0
  114. package/dist/http/middleware/views.mjs.map +1 -0
  115. package/dist/http/query/index.d.mts +3 -0
  116. package/dist/http/query/index.mjs +12 -0
  117. package/dist/http/{router-builder.d.ts → router-builder.d.mts} +9 -5
  118. package/dist/http/router-builder.d.mts.map +1 -0
  119. package/dist/http/router-builder.mjs +67 -0
  120. package/dist/http/router-builder.mjs.map +1 -0
  121. package/dist/index-4VM4dUJf.d.mts +107 -0
  122. package/dist/index-4VM4dUJf.d.mts.map +1 -0
  123. package/dist/index-rnK23QBD.d.mts +184 -0
  124. package/dist/index-rnK23QBD.d.mts.map +1 -0
  125. package/dist/index.d.mts +133 -0
  126. package/dist/index.d.mts.map +1 -0
  127. package/dist/index.mjs +126 -0
  128. package/dist/index.mjs.map +1 -0
  129. package/dist/interfaces-D5ohYl6D.d.mts +52 -0
  130. package/dist/interfaces-D5ohYl6D.d.mts.map +1 -0
  131. package/dist/logger-BLdfUF5b.d.mts +119 -0
  132. package/dist/logger-BLdfUF5b.d.mts.map +1 -0
  133. package/dist/metadata-BqXgNTOf.mjs +76 -0
  134. package/dist/metadata-BqXgNTOf.mjs.map +1 -0
  135. package/dist/{core/path.d.ts → path-Dq5V-i-x.d.mts} +7 -3
  136. package/dist/path-Dq5V-i-x.d.mts.map +1 -0
  137. package/dist/plugin-D20muJwC.d.mts +95 -0
  138. package/dist/plugin-D20muJwC.d.mts.map +1 -0
  139. package/dist/query-vljPDFaZ.mjs +164 -0
  140. package/dist/query-vljPDFaZ.mjs.map +1 -0
  141. package/dist/{core/reactivity.d.ts → reactivity-CMAQh0gi.d.mts} +21 -20
  142. package/dist/reactivity-CMAQh0gi.d.mts.map +1 -0
  143. package/package.json +73 -43
  144. package/dist/chunk-DVVP7zzD.js +0 -7
  145. package/dist/core/adapter.d.ts +0 -109
  146. package/dist/core/adapter.d.ts.map +0 -1
  147. package/dist/core/adapter.js +0 -0
  148. package/dist/core/app-module.d.ts +0 -28
  149. package/dist/core/app-module.d.ts.map +0 -1
  150. package/dist/core/app-module.js +0 -0
  151. package/dist/core/cache.d.ts.map +0 -1
  152. package/dist/core/cache.js +0 -57
  153. package/dist/core/container.d.ts +0 -63
  154. package/dist/core/container.d.ts.map +0 -1
  155. package/dist/core/container.js +0 -117
  156. package/dist/core/cron.d.ts.map +0 -1
  157. package/dist/core/cron.js +0 -22
  158. package/dist/core/decorators.d.ts +0 -153
  159. package/dist/core/decorators.d.ts.map +0 -1
  160. package/dist/core/decorators.js +0 -141
  161. package/dist/core/errors.d.ts +0 -64
  162. package/dist/core/errors.d.ts.map +0 -1
  163. package/dist/core/errors.js +0 -67
  164. package/dist/core/index.d.ts +0 -14
  165. package/dist/core/index.d.ts.map +0 -1
  166. package/dist/core/interfaces.d.ts +0 -44
  167. package/dist/core/interfaces.d.ts.map +0 -1
  168. package/dist/core/interfaces.js +0 -25
  169. package/dist/core/logger.d.ts +0 -43
  170. package/dist/core/logger.d.ts.map +0 -1
  171. package/dist/core/logger.js +0 -54
  172. package/dist/core/path.d.ts.map +0 -1
  173. package/dist/core/path.js +0 -12
  174. package/dist/core/plugin.d.ts +0 -90
  175. package/dist/core/plugin.d.ts.map +0 -1
  176. package/dist/core/plugin.js +0 -0
  177. package/dist/core/reactivity.d.ts.map +0 -1
  178. package/dist/core/reactivity.js +0 -101
  179. package/dist/core-B6Okew3W.js +0 -7
  180. package/dist/http/application.d.ts +0 -103
  181. package/dist/http/application.d.ts.map +0 -1
  182. package/dist/http/application.js +0 -167
  183. package/dist/http/bootstrap.d.ts +0 -22
  184. package/dist/http/bootstrap.d.ts.map +0 -1
  185. package/dist/http/bootstrap.js +0 -40
  186. package/dist/http/context.d.ts +0 -129
  187. package/dist/http/context.d.ts.map +0 -1
  188. package/dist/http/context.js +0 -115
  189. package/dist/http/index.d.ts +0 -16
  190. package/dist/http/index.d.ts.map +0 -1
  191. package/dist/http/middleware/cors.d.ts +0 -43
  192. package/dist/http/middleware/cors.d.ts.map +0 -1
  193. package/dist/http/middleware/cors.js +0 -31
  194. package/dist/http/middleware/csrf.d.ts +0 -47
  195. package/dist/http/middleware/csrf.d.ts.map +0 -1
  196. package/dist/http/middleware/csrf.js +0 -25
  197. package/dist/http/middleware/error-handler.d.ts +0 -6
  198. package/dist/http/middleware/error-handler.d.ts.map +0 -1
  199. package/dist/http/middleware/error-handler.js +0 -37
  200. package/dist/http/middleware/helmet.d.ts +0 -36
  201. package/dist/http/middleware/helmet.d.ts.map +0 -1
  202. package/dist/http/middleware/helmet.js +0 -20
  203. package/dist/http/middleware/rate-limit.d.ts +0 -51
  204. package/dist/http/middleware/rate-limit.d.ts.map +0 -1
  205. package/dist/http/middleware/rate-limit.js +0 -46
  206. package/dist/http/middleware/request-id.d.ts +0 -5
  207. package/dist/http/middleware/request-id.d.ts.map +0 -1
  208. package/dist/http/middleware/request-id.js +0 -12
  209. package/dist/http/middleware/request-logger.d.ts +0 -27
  210. package/dist/http/middleware/request-logger.d.ts.map +0 -1
  211. package/dist/http/middleware/request-logger.js +0 -16
  212. package/dist/http/middleware/session.d.ts +0 -62
  213. package/dist/http/middleware/session.d.ts.map +0 -1
  214. package/dist/http/middleware/session.js +0 -76
  215. package/dist/http/middleware/spa.d.ts +0 -93
  216. package/dist/http/middleware/spa.d.ts.map +0 -1
  217. package/dist/http/middleware/spa.js +0 -52
  218. package/dist/http/middleware/upload.d.ts.map +0 -1
  219. package/dist/http/middleware/upload.js +0 -119
  220. package/dist/http/middleware/validate.d.ts +0 -13
  221. package/dist/http/middleware/validate.d.ts.map +0 -1
  222. package/dist/http/middleware/validate.js +0 -45
  223. package/dist/http/middleware/views.d.ts +0 -56
  224. package/dist/http/middleware/views.d.ts.map +0 -1
  225. package/dist/http/middleware/views.js +0 -18
  226. package/dist/http/query/index.d.ts +0 -4
  227. package/dist/http/query/index.d.ts.map +0 -1
  228. package/dist/http/query/index.js +0 -10
  229. package/dist/http/query/parse-query.d.ts +0 -44
  230. package/dist/http/query/parse-query.d.ts.map +0 -1
  231. package/dist/http/query/types.d.ts +0 -100
  232. package/dist/http/query/types.d.ts.map +0 -1
  233. package/dist/http/router-builder.d.ts.map +0 -1
  234. package/dist/http/router-builder.js +0 -37
  235. package/dist/index.d.ts +0 -25
  236. package/dist/index.d.ts.map +0 -1
  237. package/dist/index.js +0 -103
  238. package/dist/query-Bym31XRp.js +0 -88
package/README.md CHANGED
@@ -36,7 +36,7 @@ kick new my-api && cd my-api && kick dev
36
36
 
37
37
  ```typescript
38
38
  import 'reflect-metadata'
39
- import { Controller, Get, Service, Autowired, bootstrap, RequestContext } from '@forinda/kickjs'
39
+ import { Controller, Get, Service, Autowired, bootstrap, type Ctx } from '@forinda/kickjs'
40
40
 
41
41
  @Service()
42
42
  class GreetService {
@@ -48,7 +48,7 @@ class HelloController {
48
48
  @Autowired() private greet!: GreetService
49
49
 
50
50
  @Get('/')
51
- handle(ctx: RequestContext) {
51
+ handle(ctx: Ctx) {
52
52
  ctx.json({ message: this.greet.greet('KickJS') })
53
53
  }
54
54
  }
@@ -65,18 +65,22 @@ import {
65
65
  // DI + Decorators
66
66
  Controller, Get, Post, Put, Delete, Patch,
67
67
  Service, Repository, Autowired, Inject, Value, Middleware,
68
+ createToken, // typed DI tokens: createToken<T>('name')
68
69
 
69
70
  // Application
70
- bootstrap, Application, RequestContext, buildRoutes,
71
+ bootstrap, Application, buildRoutes,
72
+ RequestContext, type Ctx, type RouteShape,
71
73
 
72
74
  // Middleware
73
75
  helmet, cors, csrf, rateLimit, requestId, requestLogger,
74
- validate, upload, session,
76
+ validate, upload, session, traceContext,
77
+
78
+ // Query parsing
79
+ parseQuery, type QueryFieldConfig, type ParsedQuery,
75
80
 
76
81
  // Utilities
77
82
  Container, HttpException, createLogger,
78
83
  ref, computed, watch,
79
- parseQuery, normalizePath,
80
84
 
81
85
  // Types
82
86
  type AppAdapter, type AdapterContext, type AppModule,
@@ -84,6 +88,45 @@ import {
84
88
  } from '@forinda/kickjs'
85
89
  ```
86
90
 
91
+ ## Typed Routes, Body, Query, and Env
92
+
93
+ Run `kick typegen` (via the CLI) to generate `KickRoutes` and `KickEnv` from
94
+ your codebase. Once generated, route handlers, request bodies, query strings,
95
+ and `@Value` injections are all type-checked end-to-end:
96
+
97
+ ```typescript
98
+ import { Controller, Post, Autowired, Value, type Ctx } from '@forinda/kickjs'
99
+ import { z } from 'zod'
100
+
101
+ const createUserBody = z.object({ name: z.string(), email: z.string().email() })
102
+
103
+ @Controller('/users')
104
+ class UserController {
105
+ // Typed env injection — keys come from KickEnv (your src/env.ts)
106
+ @Value('DATABASE_URL') private dbUrl!: string
107
+
108
+ @Post('/', { body: createUserBody })
109
+ create(ctx: Ctx<KickRoutes['POST /users']>) {
110
+ ctx.body.email // ✅ string — inferred from the Zod schema
111
+ ctx.created({ id: '1', ...ctx.body })
112
+ }
113
+ }
114
+ ```
115
+
116
+ ## Typed DI Tokens
117
+
118
+ ```typescript
119
+ import { createToken, Inject, Service } from '@forinda/kickjs'
120
+
121
+ export const USER_REPO = createToken<UserRepository>('user.repo')
122
+
123
+ @Service()
124
+ class UserService {
125
+ constructor(@Inject(USER_REPO) private readonly repo: UserRepository) {}
126
+ // repo is typed as UserRepository — no casts
127
+ }
128
+ ```
129
+
87
130
  ## Typed Adapter Hooks
88
131
 
89
132
  ```typescript
@@ -111,21 +154,21 @@ class MyAdapter implements AppAdapter {
111
154
 
112
155
  | Package | Description |
113
156
  |---------|-------------|
114
- | `@forinda/kickjs` | Core framework (DI, decorators, Express 5, middleware) |
115
- | `@forinda/kickjs-config` | Zod-based env validation, ConfigService, `@Value` |
116
- | `@forinda/kickjs-swagger` | Auto OpenAPI from decorators + Zod schemas |
117
- | `@forinda/kickjs-cli` | Scaffolding, DDD generators, custom commands |
118
- | `@forinda/kickjs-testing` | `createTestApp`, `createTestModule` |
119
- | `@forinda/kickjs-prisma` | Prisma adapter (v5/6/7) |
120
- | `@forinda/kickjs-drizzle` | Drizzle adapter, query builder |
121
- | `@forinda/kickjs-auth` | JWT, API key, OAuth strategies |
122
- | `@forinda/kickjs-ws` | WebSocket with `@WsController` |
123
- | `@forinda/kickjs-queue` | BullMQ, RabbitMQ, Kafka |
124
- | `@forinda/kickjs-cron` | `@Cron` decorator scheduling |
125
- | `@forinda/kickjs-mailer` | SMTP, Resend, SES |
126
- | `@forinda/kickjs-graphql` | `@Resolver`, `@Query`, `@Mutation` |
127
- | `@forinda/kickjs-otel` | OpenTelemetry tracing + metrics |
128
- | `@forinda/kickjs-devtools` | Debug dashboard at `/_debug` |
157
+ | [`@forinda/kickjs`](https://www.npmjs.com/package/@forinda/kickjs) | Core framework (DI, decorators, Express 5, middleware) |
158
+ | [`@forinda/kickjs-config`](https://www.npmjs.com/package/@forinda/kickjs-config) | Zod-based env validation, ConfigService, `@Value` |
159
+ | [`@forinda/kickjs-swagger`](https://www.npmjs.com/package/@forinda/kickjs-swagger) | Auto OpenAPI from decorators + Zod schemas |
160
+ | [`@forinda/kickjs-cli`](https://www.npmjs.com/package/@forinda/kickjs-cli) | Scaffolding, DDD generators, custom commands |
161
+ | [`@forinda/kickjs-testing`](https://www.npmjs.com/package/@forinda/kickjs-testing) | `createTestApp`, `createTestModule` |
162
+ | [`@forinda/kickjs-prisma`](https://www.npmjs.com/package/@forinda/kickjs-prisma) | Prisma adapter (v5/6/7) |
163
+ | [`@forinda/kickjs-drizzle`](https://www.npmjs.com/package/@forinda/kickjs-drizzle) | Drizzle adapter, query builder |
164
+ | [`@forinda/kickjs-auth`](https://www.npmjs.com/package/@forinda/kickjs-auth) | JWT, API key, OAuth strategies |
165
+ | [`@forinda/kickjs-ws`](https://www.npmjs.com/package/@forinda/kickjs-ws) | WebSocket with `@WsController` |
166
+ | [`@forinda/kickjs-queue`](https://www.npmjs.com/package/@forinda/kickjs-queue) | BullMQ, RabbitMQ, Kafka |
167
+ | [`@forinda/kickjs-cron`](https://www.npmjs.com/package/@forinda/kickjs-cron) | `@Cron` decorator scheduling |
168
+ | [`@forinda/kickjs-mailer`](https://www.npmjs.com/package/@forinda/kickjs-mailer) | SMTP, Resend, SES |
169
+ | [`@forinda/kickjs-graphql`](https://www.npmjs.com/package/@forinda/kickjs-graphql) | `@Resolver`, `@Query`, `@Mutation` |
170
+ | [`@forinda/kickjs-otel`](https://www.npmjs.com/package/@forinda/kickjs-otel) | OpenTelemetry tracing + metrics |
171
+ | [`@forinda/kickjs-devtools`](https://www.npmjs.com/package/@forinda/kickjs-devtools) | Debug dashboard at `/_debug` |
129
172
 
130
173
  ## CLI
131
174
 
@@ -0,0 +1,122 @@
1
+
2
+ import { i as Constructor, o as MaybePromise } from "./interfaces-D5ohYl6D.mjs";
3
+ import { t as Container } from "./container-CcgV8eHL.mjs";
4
+ import http from "node:http";
5
+ import { Express } from "express";
6
+
7
+ //#region src/core/adapter.d.ts
8
+ /**
9
+ * Where in the middleware pipeline an adapter's middleware should be inserted.
10
+ *
11
+ * beforeGlobal → runs before any user-defined global middleware
12
+ * afterGlobal → runs after global middleware, before module routes
13
+ * beforeRoutes → just before module routes are mounted
14
+ * afterRoutes → after module routes but before error handlers
15
+ */
16
+ type MiddlewarePhase = 'beforeGlobal' | 'afterGlobal' | 'beforeRoutes' | 'afterRoutes';
17
+ /** A middleware entry contributed by an adapter */
18
+ interface AdapterMiddleware {
19
+ /** Express-compatible handler: (req, res, next) => void */
20
+ handler: any;
21
+ /** Which phase to insert into (default: 'afterGlobal') */
22
+ phase?: MiddlewarePhase;
23
+ /** Optional path to scope the middleware to (e.g. '/api/v1/auth') */
24
+ path?: string;
25
+ }
26
+ /**
27
+ * Context passed to adapter lifecycle hooks.
28
+ * Populated by the Application — provides access to the Express app,
29
+ * DI container, http.Server, and environment info without requiring
30
+ * external type imports. Cast `app` or `server` if you need specific types.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * beforeMount({ app, container }: AdapterContext) {
35
+ * app.use(myMiddleware())
36
+ * }
37
+ * ```
38
+ */
39
+ interface AdapterContext {
40
+ /** Express application instance — fully typed */
41
+ app: Express;
42
+ /** DI container */
43
+ container: Container;
44
+ /** Node.js http.Server — only available in afterStart */
45
+ server?: http.Server;
46
+ /** Current NODE_ENV value (default: 'development') */
47
+ env: string;
48
+ /** true when NODE_ENV === 'production' */
49
+ isProduction: boolean;
50
+ }
51
+ /**
52
+ * Adapters plug into the Application lifecycle.
53
+ * Implement this to add WebSocket, database, rate limiting, docs, etc.
54
+ *
55
+ * All hooks receive an `AdapterContext` populated by the framework.
56
+ * No external type imports needed — the context is fully typed from KickJS internals.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import type { AppAdapter, AdapterContext } from '@forinda/kickjs-core/adapter'
61
+ *
62
+ * class SentryAdapter implements AppAdapter {
63
+ * name = 'SentryAdapter'
64
+ *
65
+ * beforeMount({ app, container }: AdapterContext) {
66
+ * app.use(Sentry.expressRequestHandler())
67
+ * }
68
+ *
69
+ * afterStart({ server }: AdapterContext) {
70
+ * // server is the http.Server — available after listen()
71
+ * }
72
+ *
73
+ * async shutdown() {
74
+ * await Sentry.close(2000)
75
+ * }
76
+ * }
77
+ * ```
78
+ */
79
+ interface AppAdapter {
80
+ /** Human-readable name for logging */
81
+ name?: string;
82
+ /**
83
+ * Return middleware entries to be inserted into the pipeline.
84
+ * The `phase` controls ordering relative to global middleware and routes.
85
+ */
86
+ middleware?(): AdapterMiddleware[];
87
+ /**
88
+ * Called before global middleware — register early routes (docs UI, health).
89
+ * May return a Promise — async rejections are caught and logged.
90
+ */
91
+ beforeMount?(ctx: AdapterContext): void | Promise<void>;
92
+ /**
93
+ * Called for each module route that gets mounted.
94
+ * Use this to collect route metadata (e.g. for OpenAPI spec generation).
95
+ */
96
+ onRouteMount?(controllerClass: Constructor, mountPath: string): void;
97
+ /**
98
+ * Called after modules registered, before HTTP server starts.
99
+ * May return a Promise — async rejections are caught and logged.
100
+ */
101
+ beforeStart?(ctx: AdapterContext): void | Promise<void>;
102
+ /**
103
+ * Called after the HTTP server is listening — attach to the raw http.Server.
104
+ * May return a Promise — async rejections are caught and logged.
105
+ */
106
+ afterStart?(ctx: AdapterContext): void | Promise<void>;
107
+ /**
108
+ * Called by the /health/ready endpoint. Return the health status of your adapter's
109
+ * backing service (database, Redis, queue, etc.).
110
+ */
111
+ onHealthCheck?(): Promise<{
112
+ name: string;
113
+ status: 'up' | 'down';
114
+ }>;
115
+ /** Called on shutdown — clean up connections */
116
+ shutdown?(): MaybePromise;
117
+ }
118
+ /** Constructor type for AppAdapter classes */
119
+ type AppAdapterClass = new () => AppAdapter;
120
+ //#endregion
121
+ export { MiddlewarePhase as a, AppAdapterClass as i, AdapterMiddleware as n, AppAdapter as r, AdapterContext as t };
122
+ //# sourceMappingURL=adapter-wuoBNkNs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-wuoBNkNs.d.mts","names":[],"sources":["../src/core/adapter.ts"],"mappings":";;;;;;;;;AAaA;;;;;AAGA;KAHY,eAAA;;UAGK,iBAAA;EAEf;EAAA,OAAA;EAEQ;EAAR,KAAA,GAAQ,eAAA;EAEJ;EAAJ,IAAA;AAAA;;;;;;;;;;;;;;UAgBe,cAAA;EAQf;EANA,GAAA,EAAK,OAAA;EAQO;EANZ,SAAA,EAAW,SAAA;EAqCI;EAnCf,MAAA,GAAS,IAAA,CAAK,MAAA;;EAEd,GAAA;EA+CkB;EA7ClB,YAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+Be,UAAA;EAsCa;EApC5B,IAAA;EAuCA;;;;EAjCA,UAAA,KAAe,iBAAA;EAqCU;;;;EA/BzB,WAAA,EAAa,GAAA,EAAK,cAAA,UAAwB,OAAA;;;;;EAM1C,YAAA,EAAc,eAAA,EAAiB,WAAA,EAAa,SAAA;;;;;EAM5C,WAAA,EAAa,GAAA,EAAK,cAAA,UAAwB,OAAA;;;;;EAM1C,UAAA,EAAY,GAAA,EAAK,cAAA,UAAwB,OAAA;;;;;EAMzC,aAAA,KAAkB,OAAA;IAAU,IAAA;IAAc,MAAA;EAAA;;EAG1C,QAAA,KAAa,YAAA;AAAA;;KAIH,eAAA,aAA4B,UAAA"}
@@ -0,0 +1,40 @@
1
+
2
+ import { t as Container } from "./container-CcgV8eHL.mjs";
3
+
4
+ //#region src/core/app-module.d.ts
5
+ /**
6
+ * Route set returned by a module's routes() method.
7
+ * Combined with versioning: /{apiPrefix}/v{version}{path}
8
+ */
9
+ interface ModuleRoutes {
10
+ /** URL prefix (e.g. '/users') */
11
+ path: string;
12
+ /** Express Router instance (from buildRoutes) */
13
+ router: any;
14
+ /** Optional API version override (defaults to Application.defaultVersion) */
15
+ version?: number;
16
+ /** Controller class for OpenAPI introspection */
17
+ controller?: any;
18
+ }
19
+ /**
20
+ * Interface that every feature module must implement.
21
+ * Modules register their DI bindings and declare their routes.
22
+ *
23
+ * `register` is **optional**. Modules that only contain decorated classes
24
+ * (`@Service`, `@Controller`, `@Repository`, `@Component`) don't need it
25
+ * because the decorators handle DI registration automatically. Implement
26
+ * `register(container)` only when you need to bind a token (typically a
27
+ * repository interface symbol) to a concrete implementation via
28
+ * `container.registerFactory()` / `container.registerInstance()`.
29
+ */
30
+ interface AppModule {
31
+ /** Optional — bind interfaces to implementations in the container */
32
+ register?(container: Container): void;
33
+ /** Return route definitions for this module, or null for non-HTTP modules */
34
+ routes(): ModuleRoutes | ModuleRoutes[] | null;
35
+ }
36
+ /** Constructor type for AppModule classes */
37
+ type AppModuleClass = new () => AppModule;
38
+ //#endregion
39
+ export { AppModuleClass as n, ModuleRoutes as r, AppModule as t };
40
+ //# sourceMappingURL=app-module-DOBmxARW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-module-DOBmxARW.d.mts","names":[],"sources":["../src/core/app-module.ts"],"mappings":";;;;;;AAMA;;UAAiB,YAAA;EAAY;EAE3B,IAAA;EAEA;EAAA,MAAA;EAIA;EAFA,OAAA;EAEU;EAAV,UAAA;AAAA;;;;;;;;;;;;UAce,SAAA;EAIsB;EAFrC,QAAA,EAAU,SAAA,EAAW,SAAA;EAMX;EAJV,MAAA,IAAU,YAAA,GAAe,YAAA;AAAA;;KAIf,cAAA,aAA2B,SAAA"}