@forinda/kickjs 8.6.0 → 9.0.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.
- package/README.md +27 -164
- package/dist/{adapter-2bnoYEPX.d.mts → adapter-DhjoIYVI.d.mts} +122 -106
- package/dist/adapter-DhjoIYVI.d.mts.map +1 -0
- package/dist/application-BnFA6J97.mjs +12 -0
- package/dist/application-BnFA6J97.mjs.map +1 -0
- package/dist/{application-_QOiAVx2.d.mts → application-DqD58rhF.d.mts} +104 -15
- package/dist/application-DqD58rhF.d.mts.map +1 -0
- package/dist/bootstrap-K1PcxSTg.mjs +12 -0
- package/dist/bootstrap-K1PcxSTg.mjs.map +1 -0
- package/dist/cache-C0qL0NSD.d.mts.map +1 -1
- package/dist/{client-ip-DF_smNX7.mjs → client-ip-DAnYuS54.mjs} +2 -2
- package/dist/{client-ip-DF_smNX7.mjs.map → client-ip-DAnYuS54.mjs.map} +1 -1
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +2 -2
- package/dist/config-16yw-Mxk.mjs +12 -0
- package/dist/config-16yw-Mxk.mjs.map +1 -0
- package/dist/container-Dw45sa0Y.mjs +132 -0
- package/dist/container-Dw45sa0Y.mjs.map +1 -0
- package/dist/context-DlIdXA6I.mjs +12 -0
- package/dist/context-DlIdXA6I.mjs.map +1 -0
- package/dist/{context-errors-Ch0DuUQo.mjs → context-errors-BqOFD7UE.mjs} +2 -2
- package/dist/{context-errors-Ch0DuUQo.mjs.map → context-errors-BqOFD7UE.mjs.map} +1 -1
- package/dist/{contributor-runner-DujKZy4N.mjs → contributor-runner-DLvBA96K.mjs} +3 -3
- package/dist/{contributor-runner-DujKZy4N.mjs.map → contributor-runner-DLvBA96K.mjs.map} +1 -1
- package/dist/core/adapter.d.mts +2 -2
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/app-module.mjs +1 -1
- package/dist/core/cache.mjs +2 -2
- package/dist/core/cache.mjs.map +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.d.mts +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/cron.mjs.map +1 -1
- package/dist/core/decorators.d.mts +1 -1
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/decorators.mjs.map +1 -1
- package/dist/core/errors.mjs +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/logger.mjs +1 -1
- package/dist/core/path.mjs +1 -1
- package/dist/core/plugin.d.mts +1 -1
- package/dist/core/plugin.mjs +1 -1
- package/dist/core/reactivity.mjs +1 -1
- package/dist/core-CCwlN0Gn.mjs +12 -0
- package/dist/{core-y8QbzHM5.mjs.map → core-CCwlN0Gn.mjs.map} +1 -1
- package/dist/cron-BTGytNg-.d.mts +122 -0
- package/dist/cron-BTGytNg-.d.mts.map +1 -0
- package/dist/{csrf-RP5hgc0c.mjs → csrf-B8CGeOlP.mjs} +3 -3
- package/dist/csrf-B8CGeOlP.mjs.map +1 -0
- package/dist/{csrf-C4MwaMp4.d.mts → csrf-COFjRrUz.d.mts} +2 -2
- package/dist/{csrf-C4MwaMp4.d.mts.map → csrf-COFjRrUz.d.mts.map} +1 -1
- package/dist/{decorate-D85rEnU-.mjs → decorate-CahyjuWW.mjs} +1 -1
- package/dist/{decorators-mg0qJ6Qc.d.mts → decorators-DOcWsXci.d.mts} +2 -2
- package/dist/{decorators-mg0qJ6Qc.d.mts.map → decorators-DOcWsXci.d.mts.map} +1 -1
- package/dist/{define-adapter-C1Db6xfO.mjs → define-adapter-Ckc2P-wH.mjs} +2 -2
- package/dist/{define-adapter-C1Db6xfO.mjs.map → define-adapter-Ckc2P-wH.mjs.map} +1 -1
- package/dist/{disposables-CEAxve3A.mjs → disposables-DnvT8DXr.mjs} +2 -2
- package/dist/{disposables-CEAxve3A.mjs.map → disposables-DnvT8DXr.mjs.map} +1 -1
- package/dist/{env-BelmDj19.mjs → env-DMAdjj8Z.mjs} +4 -4
- package/dist/env-DMAdjj8Z.mjs.map +1 -0
- package/dist/{error-handler-C1uWVGVY.d.mts → error-handler-DiueQHes.d.mts} +2 -2
- package/dist/{error-handler-C1uWVGVY.d.mts.map → error-handler-DiueQHes.d.mts.map} +1 -1
- package/dist/{handler-DHlakr0v.mjs → handler-2CbWK63p.mjs} +3 -3
- package/dist/handler-2CbWK63p.mjs.map +1 -0
- package/dist/http/application.d.mts +2 -2
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +1 -1
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +2 -2
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.d.mts +1 -1
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/error-handler.d.mts +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/error-handler.mjs.map +1 -1
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.d.mts +1 -1
- package/dist/http/middleware/session.mjs +2 -2
- package/dist/http/middleware/session.mjs.map +1 -1
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/upload.d.mts +1 -1
- package/dist/http/middleware/upload.mjs +3 -3
- package/dist/http/middleware/upload.mjs.map +1 -1
- package/dist/http/middleware/validate.mjs +1 -1
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +1 -1
- package/dist/http/router-builder.mjs +2 -2
- package/dist/http/runtimes/fastify.d.mts +1 -1
- package/dist/http/runtimes/fastify.d.mts.map +1 -1
- package/dist/http/runtimes/fastify.mjs +3 -3
- package/dist/http/runtimes/fastify.mjs.map +1 -1
- package/dist/http/runtimes/h3-web.d.mts +1 -1
- package/dist/http/runtimes/h3-web.d.mts.map +1 -1
- package/dist/http/runtimes/h3-web.mjs +2 -2
- package/dist/http/runtimes/h3-web.mjs.map +1 -1
- package/dist/http/runtimes/h3.d.mts +1 -6
- package/dist/http/runtimes/h3.d.mts.map +1 -1
- package/dist/http/runtimes/h3.mjs +2 -2
- package/dist/http/runtimes/h3.mjs.map +1 -1
- package/dist/{index-Btz1W0X5.d.mts → index-CDn-p3tq.d.mts} +27 -18
- package/dist/index-CDn-p3tq.d.mts.map +1 -0
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/jobs-C8_ESbx0.mjs +12 -0
- package/dist/jobs-C8_ESbx0.mjs.map +1 -0
- package/dist/{kv-stores-DUFcps01.mjs → kv-stores-BhUmirED.mjs} +3 -3
- package/dist/{kv-stores-DUFcps01.mjs.map → kv-stores-BhUmirED.mjs.map} +1 -1
- package/dist/{kv-stores-Dx5RvIaP.d.mts → kv-stores-CetFF9N_.d.mts} +135 -5
- package/dist/kv-stores-CetFF9N_.d.mts.map +1 -0
- package/dist/{metadata-B8_KXybT.mjs → metadata-BQG1MmqL.mjs} +2 -2
- package/dist/{metadata-B8_KXybT.mjs.map → metadata-BQG1MmqL.mjs.map} +1 -1
- package/dist/{module-registry-BFrJ1PQ4.mjs → module-registry-BXnvRtH9.mjs} +2 -2
- package/dist/{module-registry-BFrJ1PQ4.mjs.map → module-registry-BXnvRtH9.mjs.map} +1 -1
- package/dist/observers-BI8H_g45.mjs +12 -0
- package/dist/observers-BI8H_g45.mjs.map +1 -0
- package/dist/{query-CC7o6I5K.mjs → query-CRTeiKUv.mjs} +2 -2
- package/dist/{query-CC7o6I5K.mjs.map → query-CRTeiKUv.mjs.map} +1 -1
- package/dist/{respond-B-EDymxF.mjs → respond-BAxhPjRj.mjs} +2 -2
- package/dist/{respond-B-EDymxF.mjs.map → respond-BAxhPjRj.mjs.map} +1 -1
- package/dist/route-flag-B1lQht6v.d.mts.map +1 -1
- package/dist/{route-flag-B4sNP7zH.mjs → route-flag-GipNvQ4O.mjs} +3 -3
- package/dist/route-flag-GipNvQ4O.mjs.map +1 -0
- package/dist/{route-policy-CDlMbl1b.mjs → route-policy-DtGR4sar.mjs} +2 -2
- package/dist/route-policy-DtGR4sar.mjs.map +1 -0
- package/dist/{router-builder-C6gmK0nZ.d.mts → router-builder-BSBSYgYW.d.mts} +3 -3
- package/dist/{router-builder-C6gmK0nZ.d.mts.map → router-builder-BSBSYgYW.d.mts.map} +1 -1
- package/dist/{router-builder-cTsA2XtO.mjs → router-builder-C2nnS0VJ.mjs} +3 -3
- package/dist/{router-builder-cTsA2XtO.mjs.map → router-builder-C2nnS0VJ.mjs.map} +1 -1
- package/dist/{runtime-C-7Yhs7a.mjs → runtime-DGzigyO2.mjs} +3 -3
- package/dist/runtime-DGzigyO2.mjs.map +1 -0
- package/dist/{session-BHgRyfqZ.d.mts → session-4Tb6q0Ny.d.mts} +11 -1
- package/dist/session-4Tb6q0Ny.d.mts.map +1 -0
- package/dist/{upload-TW2ZuECF.d.mts → upload-DjhnyHHm.d.mts} +3 -15
- package/dist/{upload-TW2ZuECF.d.mts.map → upload-DjhnyHHm.d.mts.map} +1 -1
- package/dist/{upload-config-CoE6BzM4.mjs → upload-config-CcoZp7xA.mjs} +2 -2
- package/dist/{upload-config-CoE6BzM4.mjs.map → upload-config-CcoZp7xA.mjs.map} +1 -1
- package/dist/web.d.mts +39 -7
- package/dist/web.d.mts.map +1 -1
- package/dist/web.mjs +2 -2
- package/dist/web.mjs.map +1 -1
- package/package.json +15 -10
- package/dist/adapter-2bnoYEPX.d.mts.map +0 -1
- package/dist/application-DZiG1QCw.mjs +0 -12
- package/dist/application-DZiG1QCw.mjs.map +0 -1
- package/dist/application-_QOiAVx2.d.mts.map +0 -1
- package/dist/bootstrap-BEbka3UV.mjs +0 -12
- package/dist/bootstrap-BEbka3UV.mjs.map +0 -1
- package/dist/config-CIOXZmLS.mjs +0 -12
- package/dist/config-CIOXZmLS.mjs.map +0 -1
- package/dist/container-DF8FRoY8.mjs +0 -117
- package/dist/container-DF8FRoY8.mjs.map +0 -1
- package/dist/context-BTqeZH1A.mjs +0 -12
- package/dist/context-BTqeZH1A.mjs.map +0 -1
- package/dist/core-y8QbzHM5.mjs +0 -12
- package/dist/cron-DOOtTY4q.d.mts +0 -30
- package/dist/cron-DOOtTY4q.d.mts.map +0 -1
- package/dist/csrf-RP5hgc0c.mjs.map +0 -1
- package/dist/env-BelmDj19.mjs.map +0 -1
- package/dist/handler-DHlakr0v.mjs.map +0 -1
- package/dist/index-Btz1W0X5.d.mts.map +0 -1
- package/dist/kv-stores-Dx5RvIaP.d.mts.map +0 -1
- package/dist/route-flag-B4sNP7zH.mjs.map +0 -1
- package/dist/route-policy-CDlMbl1b.mjs.map +0 -1
- package/dist/runtime-C-7Yhs7a.mjs.map +0 -1
- package/dist/session-BHgRyfqZ.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -1,212 +1,75 @@
|
|
|
1
1
|
# @forinda/kickjs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern type-safe backend framework, powered by Vite. Built for developer experience, and pluggable as you need: DI, modules, a typed request context, validation and generators, on Express (default), Fastify or h3, and on Workers, Bun and Deno through a web-standard entry.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# Scaffold a new project (recommended) — gets you a complete layout in seconds
|
|
9
8
|
npx @forinda/kickjs-cli new my-api && cd my-api && pnpm dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or add it to an existing project:
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
```bash
|
|
12
14
|
pnpm add @forinda/kickjs express reflect-metadata zod
|
|
13
15
|
pnpm add -D @forinda/kickjs-cli @forinda/kickjs-vite
|
|
14
|
-
|
|
15
|
-
# Prefer another engine? Install its peer and swap one line (see HTTP Runtimes):
|
|
16
|
-
# pnpm add fastify @fastify/middie → runtime: fastifyRuntime()
|
|
17
|
-
# pnpm add h3 → runtime: h3Runtime()
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
The CLI scaffolds a complete layout. The files below show the canonical shapes — copy them into an existing project if you're not using `kick new`.
|
|
23
|
-
|
|
24
|
-
### 1. Service (`@Service` + DI)
|
|
18
|
+
## Quick example
|
|
25
19
|
|
|
26
20
|
```ts
|
|
27
|
-
// src/modules/users/user.
|
|
28
|
-
import { Service } from '@forinda/kickjs'
|
|
21
|
+
// src/modules/users/user.controller.ts
|
|
22
|
+
import { Autowired, Controller, Get, Post, Service, type Ctx } from '@forinda/kickjs'
|
|
23
|
+
import { z } from 'zod'
|
|
29
24
|
|
|
30
25
|
@Service()
|
|
31
26
|
export class UserService {
|
|
32
27
|
list() {
|
|
33
28
|
return [{ id: '1', name: 'Alice' }]
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
create(input: { name: string; email: string }) {
|
|
37
|
-
return { id: '2', ...input }
|
|
38
|
-
}
|
|
39
30
|
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 2. Controller (`@Controller`, decorators, typed `ctx`)
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
// src/modules/users/user.controller.ts
|
|
46
|
-
import { Controller, Get, Post, Autowired, type Ctx } from '@forinda/kickjs'
|
|
47
|
-
import { z } from 'zod'
|
|
48
|
-
import { UserService } from './user.service'
|
|
49
|
-
|
|
50
|
-
const createUserSchema = z.object({
|
|
51
|
-
name: z.string().min(1),
|
|
52
|
-
email: z.string().email(),
|
|
53
|
-
})
|
|
54
31
|
|
|
55
32
|
@Controller()
|
|
56
33
|
export class UserController {
|
|
57
34
|
@Autowired() private readonly users!: UserService
|
|
58
35
|
|
|
59
36
|
@Get('/')
|
|
60
|
-
list(
|
|
61
|
-
|
|
37
|
+
list() {
|
|
38
|
+
return this.users.list()
|
|
62
39
|
}
|
|
63
40
|
|
|
64
|
-
@Post('/', { body:
|
|
41
|
+
@Post('/', { body: z.object({ name: z.string().min(1) }) })
|
|
65
42
|
create(ctx: Ctx<KickRoutes.UserController['create']>) {
|
|
66
|
-
|
|
67
|
-
ctx.created(this.users.create(ctx.body))
|
|
43
|
+
ctx.created({ id: '2', name: ctx.body.name })
|
|
68
44
|
}
|
|
69
45
|
}
|
|
70
46
|
```
|
|
71
47
|
|
|
72
|
-
`Ctx<KickRoutes.UserController['list']>` is generated by `kick typegen` (auto-runs on `kick dev`) — `ctx.params`, `ctx.body`, `ctx.query` all narrow to the Zod-derived shape as you save.
|
|
73
|
-
|
|
74
|
-
### 3. Module (`defineModule()` factory)
|
|
75
|
-
|
|
76
|
-
```ts
|
|
77
|
-
// src/modules/users/user.module.ts
|
|
78
|
-
import { defineModule } from '@forinda/kickjs'
|
|
79
|
-
import { UserController } from './user.controller'
|
|
80
|
-
|
|
81
|
-
export const UserModule = defineModule({
|
|
82
|
-
name: 'UserModule',
|
|
83
|
-
build: () => ({
|
|
84
|
-
routes() {
|
|
85
|
-
return { path: '/users', controller: UserController }
|
|
86
|
-
},
|
|
87
|
-
}),
|
|
88
|
-
})
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
The framework derives the router from `controller` — never import `buildRoutes` directly. `path` is the **single source of truth** for the mount prefix; `@Controller()` takes no path argument.
|
|
92
|
-
|
|
93
|
-
### 4. Module registry (`defineModules()` fluent chain)
|
|
94
|
-
|
|
95
|
-
```ts
|
|
96
|
-
// src/modules/index.ts
|
|
97
|
-
import { defineModules } from '@forinda/kickjs'
|
|
98
|
-
import { UserModule } from './users/user.module'
|
|
99
|
-
|
|
100
|
-
// Factories are called at the registration site — `UserModule()` produces
|
|
101
|
-
// the AppModule instance bootstrap registers. Each `.mount(...)` call adds
|
|
102
|
-
// one module; chain as many as you need.
|
|
103
|
-
export const modules = defineModules().mount(UserModule())
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 5. Bootstrap entry
|
|
107
|
-
|
|
108
48
|
```ts
|
|
109
49
|
// src/index.ts
|
|
110
50
|
import 'reflect-metadata'
|
|
111
|
-
import
|
|
112
|
-
import {
|
|
113
|
-
import { modules } from './modules'
|
|
114
|
-
|
|
115
|
-
// Always export the app. The Vite plugin reads this symbol to wire HMR;
|
|
116
|
-
// skipping `export` works in production but degrades dev mode to full restarts.
|
|
117
|
-
export const app = await bootstrap({ modules })
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
That's it — `http://localhost:3000/api/v1/users` returns Alice; `POST /api/v1/users` with `{ name, email }` validates against the Zod schema.
|
|
121
|
-
|
|
122
|
-
## HTTP Runtimes — Express, Fastify, or h3
|
|
123
|
-
|
|
124
|
-
The HTTP engine is pluggable. Controllers, DI, decorators, and `ctx` are engine-neutral; pick the engine in `bootstrap()` (Express is the default — no import needed):
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
import { bootstrap } from '@forinda/kickjs'
|
|
128
|
-
import { fastifyRuntime } from '@forinda/kickjs/fastify' // or @forinda/kickjs/h3 → h3Runtime
|
|
129
|
-
|
|
130
|
-
export const app = await bootstrap({ modules, runtime: fastifyRuntime() })
|
|
131
|
-
```
|
|
51
|
+
import { bootstrap, defineModule, defineModules } from '@forinda/kickjs'
|
|
52
|
+
import { UserController } from './modules/users/user.controller'
|
|
132
53
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
import { h3WebRuntime } from '@forinda/kickjs/h3-web' // bootstrap() on node, WHATWG pipeline
|
|
139
|
-
import { createWebApp } from '@forinda/kickjs/web' // fetch(Request) → Response — Workers / Bun / Deno
|
|
140
|
-
import * as h3 from 'h3' // v2 — passed in: edge bundlers have no createRequire
|
|
141
|
-
import { modules } from './modules'
|
|
142
|
-
|
|
143
|
-
const app = createWebApp({ h3, modules })
|
|
144
|
-
export default { fetch: (req: Request) => app.fetch(req) }
|
|
145
|
-
```
|
|
54
|
+
const UserModule = defineModule({
|
|
55
|
+
name: 'UserModule',
|
|
56
|
+
build: () => ({ routes: () => ({ path: '/users', controller: UserController }) }),
|
|
57
|
+
})
|
|
146
58
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
## Project Layout
|
|
150
|
-
|
|
151
|
-
`kick new` produces this convention; everything except the bootstrap entry is configurable via `kick.config.ts`:
|
|
152
|
-
|
|
153
|
-
```text
|
|
154
|
-
src/
|
|
155
|
-
index.ts # bootstrap entry — exports `app`
|
|
156
|
-
config/index.ts # env schema via defineEnv() + loadEnv()
|
|
157
|
-
modules/
|
|
158
|
-
index.ts # defineModules() chain
|
|
159
|
-
<name>/<name>.module.ts # one module per feature
|
|
160
|
-
<name>/<name>.controller.ts
|
|
161
|
-
<name>/<name>.service.ts
|
|
162
|
-
middleware/ # optional — `@Middleware()` factories + global stack
|
|
163
|
-
adapters/ # optional — `defineAdapter()` integrations
|
|
164
|
-
plugins/ # optional — `definePlugin()` bundles
|
|
165
|
-
.agents/ # AI agent context — AGENTS.md + skills/<slug>/SKILL.md
|
|
166
|
-
CLAUDE.md # Claude Code root (thin pointer to .agents/)
|
|
167
|
-
kick.config.ts # CLI configuration (optional)
|
|
168
|
-
vite.config.ts # Vite + KickJS HMR
|
|
59
|
+
export const app = await bootstrap({ modules: defineModules().mount(UserModule()) })
|
|
169
60
|
```
|
|
170
61
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
- **Pluggable HTTP runtimes** — one `HttpRuntime` seam over Express (default), Fastify, or h3. Swap the engine in one line; everything above stays the same. See [HTTP Runtimes](https://kickjs.app/guide/http-runtimes.html).
|
|
174
|
-
- **Return-value handlers + typed client** — `return` the payload (`reply(201, body)` for other statuses) and the response type flows through `kick typegen` into `KickRoutes.Api`, consumed by [`@forinda/kickjs-client`](https://kickjs.app/guide/typed-client.html) on the frontend. Declare `{ response: schema }` on a route and the same contract feeds the OpenAPI success response. See [Controllers](https://kickjs.app/guide/controllers.html#return-value-handlers), [Typed Client](https://kickjs.app/guide/typed-client.html).
|
|
175
|
-
- **First-class database** — `kick/db`: code-first schema, fully typed queries, and migrations for PostgreSQL / SQLite / MySQL. `kick add db` (or `pg` / `sqlite` / `mysql`). See [Database](https://kickjs.app/guide/database/).
|
|
176
|
-
- **Custom DI container** — three scopes (singleton / transient / request), slash-delimited tokens (`createToken<T>('app/users/repository')`), constructor + property injection. No external DI dep. See [Dependency Injection](https://kickjs.app/guide/dependency-injection.html).
|
|
177
|
-
- **Factory-first** — `defineAdapter()`, `definePlugin()`, `defineModule()`, `defineHttpContextDecorator()`. No class hierarchies to inherit from. See [Adapters](https://kickjs.app/guide/adapters.html), [Plugins](https://kickjs.app/guide/plugins.html).
|
|
178
|
-
- **Context Contributors** — replace single-purpose middleware that only sets `ctx` values. Typed `dependsOn` (typos are TS errors, not boot-time crashes), topo-sorted at startup. (`@forinda/kickjs-ws` handlers don't run contributors — a socket isn't a request.) See [Context Decorators](https://kickjs.app/guide/context-decorators.html).
|
|
179
|
-
- **Built-in health probes** — `GET /health/live` and `GET /health/ready` ship as a module, mounted at the root outside `apiPrefix` so a probe URL an orchestrator is configured against does not move. Readiness runs every adapter's `onHealthCheck()`. They sit inside your middleware chain, so app-wide auth applies — pass `bootstrap({ health: false })` to mount your own.
|
|
180
|
-
- **Env wiring** — `defineEnv()` + `loadEnv()` in `src/config/index.ts`. The `import './config'` side-effect import at the top of `src/index.ts` MUST happen before any `@Value()` injection resolves. See [Configuration](https://kickjs.app/guide/configuration.html).
|
|
181
|
-
- **Asset Manager** — typed `assets.<ns>.<key>()` accessor, configured via `assetMap` in `kick.config.ts`. Drops the `__dirname` arithmetic that production builds get wrong. See [Asset Manager](https://kickjs.app/guide/asset-manager.html).
|
|
182
|
-
- **Reactive primitives** — `ref()` / `computed()` / `reactive()` / `watch()` Vue-style; `ref` and `computed` auto-unwrap on `JSON.stringify` so they drop straight into `introspect()` snapshots.
|
|
183
|
-
- **DevTools** — `/_debug` browser panel with topology, container, contributors, metrics. Adapters expose state via `introspect(): IntrospectionSnapshot` (type lives in `@forinda/kickjs` — no extra import needed). See [DevTools](https://kickjs.app/guide/devtools.html).
|
|
184
|
-
|
|
185
|
-
## Common Add-Ons
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
kick add db # kick/db — typed, code-first DB (+ pg / sqlite / mysql)
|
|
189
|
-
kick add upload # file-upload driver for your runtime (multer / @fastify/multipart / native)
|
|
190
|
-
kick add swagger # OpenAPI docs from decorators + Zod schemas
|
|
191
|
-
kick add devtools # /_debug dashboard
|
|
192
|
-
kick add ws # WebSocket with @WsController, rooms, heartbeat
|
|
193
|
-
kick add queue # BullMQ / RabbitMQ / Kafka jobs
|
|
194
|
-
kick add testing # createTestApp + createTestModule helpers
|
|
195
|
-
kick add --list # full live catalog
|
|
196
|
-
|
|
197
|
-
kick doctor # pre-flight checks: engine peers, upload driver, env wiring
|
|
198
|
-
```
|
|
62
|
+
`GET /api/v1/users` returns the list. `KickRoutes` comes from `kick typegen`, which `kick dev` runs for you. To use another engine, pass `runtime: fastifyRuntime()` (from `@forinda/kickjs/fastify`) or `h3Runtime()` to `bootstrap()`.
|
|
199
63
|
|
|
200
64
|
## Documentation
|
|
201
65
|
|
|
202
|
-
**[kickjs.app](https://kickjs.app/)
|
|
203
|
-
|
|
204
|
-
Start here:
|
|
66
|
+
**[kickjs.app](https://kickjs.app/)**. Good places to start:
|
|
205
67
|
|
|
206
|
-
- [Getting Started](https://kickjs.app/guide/getting-started
|
|
207
|
-
- [Modules](https://kickjs.app/guide/modules
|
|
208
|
-
- [
|
|
209
|
-
- [
|
|
68
|
+
- [Getting Started](https://kickjs.app/guide/getting-started)
|
|
69
|
+
- [Modules](https://kickjs.app/guide/modules), [Controllers](https://kickjs.app/guide/controllers), [Dependency Injection](https://kickjs.app/guide/dependency-injection)
|
|
70
|
+
- [HTTP Runtimes](https://kickjs.app/guide/http-runtimes), [Edge Deployment](https://kickjs.app/guide/edge-deployment)
|
|
71
|
+
- [Context Decorators](https://kickjs.app/guide/context-decorators), [Adapters](https://kickjs.app/guide/adapters), [Plugins](https://kickjs.app/guide/plugins)
|
|
72
|
+
- [BYO Recipes](https://kickjs.app/guide/byo-recipes): auth, GraphQL, OpenTelemetry, cron, mailer, multi-tenancy
|
|
210
73
|
|
|
211
74
|
## License
|
|
212
75
|
|
|
@@ -1,15 +1,53 @@
|
|
|
1
1
|
|
|
2
2
|
import { i as Constructor, o as MaybePromise } from "./interfaces-C1hCSoLD.mjs";
|
|
3
3
|
import { s as InjectionToken, t as Container } from "./container-Dpvd66Yt.mjs";
|
|
4
|
-
import { g as FileUploadConfig, k as RouteDefinition, x as MiddlewareHandler } from "./decorators-
|
|
4
|
+
import { g as FileUploadConfig, k as RouteDefinition, x as MiddlewareHandler } from "./decorators-DOcWsXci.mjs";
|
|
5
5
|
import { p as RouteFlags } from "./route-flag-B1lQht6v.mjs";
|
|
6
6
|
import { C as MetaValue, S as ExecutionContext, m as ContributorRegistrations, o as AnyContributorRegistration, r as AppModuleEntry, t as AppModule, x as ContextMetaKey } from "./app-module-DCA65GZZ.mjs";
|
|
7
7
|
import "./cache-C0qL0NSD.mjs";
|
|
8
8
|
import { i as ProblemDetails } from "./errors-By6UueCm.mjs";
|
|
9
|
+
import { t as Session } from "./session-4Tb6q0Ny.mjs";
|
|
9
10
|
import { S as QueryFieldConfig, T as TypedParsedQuery, t as ParseQueryOptions, v as PaginatedResponse } from "./index-BfT5KZ-M.mjs";
|
|
10
11
|
import "reflect-metadata";
|
|
11
12
|
import http, { IncomingMessage, ServerResponse } from "node:http";
|
|
13
|
+
import https from "node:https";
|
|
14
|
+
import http2 from "node:http2";
|
|
12
15
|
import { ErrorRequestHandler, Express as Express$1, NextFunction, Request as Request$1, RequestHandler, Response as Response$1 } from "express";
|
|
16
|
+
//#region src/core/observers.d.ts
|
|
17
|
+
/** Where an error came from. Integrations may report their own sources. */
|
|
18
|
+
type ErrorSource = 'request' | 'uncaught' | 'unhandled-rejection' | 'background' | 'job' | (string & {});
|
|
19
|
+
interface ErrorInfo {
|
|
20
|
+
source: ErrorSource;
|
|
21
|
+
requestId?: string;
|
|
22
|
+
method?: string;
|
|
23
|
+
/** The request URL path, as received. */
|
|
24
|
+
path?: string;
|
|
25
|
+
/** The matched route pattern, e.g. `/api/v1/users/:id`, when one matched. */
|
|
26
|
+
route?: string;
|
|
27
|
+
/** The status the error was answered with, for request errors. */
|
|
28
|
+
status?: number;
|
|
29
|
+
/** Anything else the reporter knows — a queue and job name, a cron schedule. */
|
|
30
|
+
context?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
interface ResponseInfo {
|
|
33
|
+
method: string;
|
|
34
|
+
path: string;
|
|
35
|
+
/** The matched route pattern, or undefined when no route matched (404s). */
|
|
36
|
+
route?: string;
|
|
37
|
+
status: number;
|
|
38
|
+
durationMs: number;
|
|
39
|
+
requestId?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Report an error to every observer. The framework calls this for request
|
|
43
|
+
* errors, uncaught exceptions, unhandled rejections, `waitUntil` failures and
|
|
44
|
+
* queue job failures; call it from your own integrations too (a cron runner,
|
|
45
|
+
* a message consumer). Never throws.
|
|
46
|
+
*/
|
|
47
|
+
declare function reportError(error: unknown, info: ErrorInfo): void;
|
|
48
|
+
/** Report a finished response to every observer. Never throws. */
|
|
49
|
+
declare function reportResponse(info: ResponseInfo): void;
|
|
50
|
+
//#endregion
|
|
13
51
|
//#region src/core/introspect.d.ts
|
|
14
52
|
/**
|
|
15
53
|
* Per-primitive introspection snapshot — the JSON shape an adapter or
|
|
@@ -80,8 +118,8 @@ type IntrospectFn = () => IntrospectionSnapshot | Promise<IntrospectionSnapshot>
|
|
|
80
118
|
//#endregion
|
|
81
119
|
//#region src/core/augmentation.d.ts
|
|
82
120
|
/**
|
|
83
|
-
*
|
|
84
|
-
* `
|
|
121
|
+
* The canonical `KickJsPluginRegistry` interface that `kick typegen`
|
|
122
|
+
* augments, for typed `dependsOn` between plugins and adapters.
|
|
85
123
|
*
|
|
86
124
|
* See `architecture.md` §21.2.1 (typegen for `dependsOn`) and §21.3.3
|
|
87
125
|
* (standardized augmentation registry) for the design rationale.
|
|
@@ -109,103 +147,6 @@ interface KickJsPluginRegistry {}
|
|
|
109
147
|
* narrowing is a progressive enhancement, not a hard prerequisite.
|
|
110
148
|
*/
|
|
111
149
|
type KickJsPluginName = keyof KickJsPluginRegistry extends never ? string : keyof KickJsPluginRegistry & string;
|
|
112
|
-
/**
|
|
113
|
-
* Metadata attached to a `defineAugmentation` call. The fields are
|
|
114
|
-
* documentation-only — `kick typegen` surfaces them in the generated
|
|
115
|
-
* `.kickjs/types/kick__augmentations.d.ts` so adopters can browse every
|
|
116
|
-
* augmentable interface from one place.
|
|
117
|
-
*
|
|
118
|
-
* `description` and `example` may both be multi-line — typegen preserves
|
|
119
|
-
* line breaks when rendering them as JSDoc. There is no upper limit on
|
|
120
|
-
* the example size; entire shape definitions or worked snippets are fine.
|
|
121
|
-
*/
|
|
122
|
-
interface AugmentationMeta {
|
|
123
|
-
/**
|
|
124
|
-
* Free-form description of what the augmentation customises. May be
|
|
125
|
-
* multi-line — newlines are preserved in the generated JSDoc.
|
|
126
|
-
*/
|
|
127
|
-
description?: string;
|
|
128
|
-
/**
|
|
129
|
-
* TS snippet showing a typical shape. May be multi-line; rendered
|
|
130
|
-
* inside a fenced code block in the generated catalogue. Use this
|
|
131
|
-
* for anything from `'{ foo: string }'` up to a full interface body
|
|
132
|
-
* — typegen no longer flattens newlines.
|
|
133
|
-
*/
|
|
134
|
-
example?: string;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* @deprecated Since 7.2. This was tooling for a time when Context
|
|
138
|
-
* Contributors were still settling — a catalogue so adopters could discover
|
|
139
|
-
* which interfaces were augmentable. Contributors are a stable, typed API now
|
|
140
|
-
* (`defineContextDecorator`, `ContextMeta`), and the catalogue adds a second
|
|
141
|
-
* call that must be kept in step with the `declare module` block for no
|
|
142
|
-
* type-level benefit.
|
|
143
|
-
*
|
|
144
|
-
* Nothing breaks: `kick typegen` still discovers the call and still writes the
|
|
145
|
-
* catalogue. Just drop it — the `declare module '@forinda/kickjs'` block alone
|
|
146
|
-
* gives you the types, which is all it ever gave you.
|
|
147
|
-
*
|
|
148
|
-
* What it actually emits, for the record: one empty marker interface per call
|
|
149
|
-
* in `.kickjs/types/kick__augmentations.d.ts` —
|
|
150
|
-
*
|
|
151
|
-
* ```ts
|
|
152
|
-
* // from defineAugmentation('ContextMeta', { description, example })
|
|
153
|
-
* export interface ContextMetaAugmentation {}
|
|
154
|
-
* ```
|
|
155
|
-
*
|
|
156
|
-
* with your `description` / `example` rendered as its JSDoc and a `@see` back
|
|
157
|
-
* to the call site. The interface is empty and unreferenced; nothing consumes
|
|
158
|
-
* it at type level.
|
|
159
|
-
*
|
|
160
|
-
* Advertise an augmentable interface so `kick typegen` can list it in
|
|
161
|
-
* `.kickjs/types/kick__augmentations.d.ts` for project-wide discovery.
|
|
162
|
-
*
|
|
163
|
-
* **This function is a runtime AND type-level no-op.** It does NOT
|
|
164
|
-
* augment the interface for TypeScript. The actual augmentation is
|
|
165
|
-
* the `declare module` block — `defineAugmentation` only adds an
|
|
166
|
-
* entry to the typegen catalogue (`.kickjs/types/kick__augmentations.d.ts`)
|
|
167
|
-
* so other contributors / adopters can find the interface and know its
|
|
168
|
-
* expected shape.
|
|
169
|
-
*
|
|
170
|
-
* Both calls are needed:
|
|
171
|
-
*
|
|
172
|
-
* ```ts
|
|
173
|
-
* import { defineAugmentation } from '@forinda/kickjs'
|
|
174
|
-
*
|
|
175
|
-
* // (1) The actual TS augmentation — what `ctx.get('tenant')` reads.
|
|
176
|
-
* declare module '@forinda/kickjs' {
|
|
177
|
-
* interface ContextMeta {
|
|
178
|
-
* tenant: { id: string; name: string }
|
|
179
|
-
* }
|
|
180
|
-
* }
|
|
181
|
-
*
|
|
182
|
-
* // (2) Catalogue entry — what `kick typegen` lists in
|
|
183
|
-
* // `.kickjs/types/kick__augmentations.d.ts` for browseability.
|
|
184
|
-
* defineAugmentation('ContextMeta', {
|
|
185
|
-
* description: 'Tenant resolved from x-tenant-id by TenantAdapter',
|
|
186
|
-
* example: `{
|
|
187
|
-
* tenant: {
|
|
188
|
-
* id: string
|
|
189
|
-
* name: string
|
|
190
|
-
* plan: 'free' | 'pro' | 'enterprise'
|
|
191
|
-
* featureFlags: Record<string, boolean>
|
|
192
|
-
* }
|
|
193
|
-
* }`,
|
|
194
|
-
* })
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* Skip `defineAugmentation` if you don't care about the catalogue — the
|
|
198
|
-
* `declare module` block alone is enough for runtime + type behaviour.
|
|
199
|
-
*
|
|
200
|
-
* @deprecated Low value in practice: it does nothing at runtime or at
|
|
201
|
-
* the type level — the `declare module` block alone gives you the
|
|
202
|
-
* augmentation, and the generated `.kickjs/types/kick__augmentations.d.ts`
|
|
203
|
-
* catalogue it feeds is documentation-only. Prefer a plain
|
|
204
|
-
* `declare module '@forinda/kickjs' { ... }` block and (optionally) a
|
|
205
|
-
* JSDoc comment on your own interface. `defineAugmentation` and the
|
|
206
|
-
* `kick/augmentations` typegen plugin will be removed in a future major.
|
|
207
|
-
*/
|
|
208
|
-
declare function defineAugmentation(name: string, meta?: AugmentationMeta): void;
|
|
209
150
|
//#endregion
|
|
210
151
|
//#region src/core/module-registry.d.ts
|
|
211
152
|
/**
|
|
@@ -436,6 +377,19 @@ interface KickPlugin {
|
|
|
436
377
|
* Use for post-startup logic like logging, health registration, etc.
|
|
437
378
|
*/
|
|
438
379
|
onReady?(container: Container): void | Promise<void>;
|
|
380
|
+
/**
|
|
381
|
+
* Observe every error the app reports — request errors (any status; filter
|
|
382
|
+
* on `info.status`), uncaught exceptions, unhandled rejections, failed
|
|
383
|
+
* `waitUntil` work, failed queue jobs, and anything passed to
|
|
384
|
+
* `reportError()`. Observe-only: the response is not yours to change, and a
|
|
385
|
+
* throw here is logged and skipped. The place to wire Sentry & co.
|
|
386
|
+
*/
|
|
387
|
+
onError?(error: unknown, info: ErrorInfo): void | Promise<void>;
|
|
388
|
+
/**
|
|
389
|
+
* Observe every finished response — method, path, the matched route
|
|
390
|
+
* pattern, status, duration. Only timed while something listens.
|
|
391
|
+
*/
|
|
392
|
+
onResponse?(info: ResponseInfo): void | Promise<void>;
|
|
439
393
|
/**
|
|
440
394
|
* Called during application shutdown — release what this plugin owns
|
|
441
395
|
* (connections, intervals, subscriptions).
|
|
@@ -1189,8 +1143,17 @@ TKeys extends ContextMetaKey = ContextMetaKey> implements ExecutionContext<TKeys
|
|
|
1189
1143
|
* idempotent).
|
|
1190
1144
|
*/
|
|
1191
1145
|
get signal(): AbortSignal;
|
|
1192
|
-
/**
|
|
1193
|
-
|
|
1146
|
+
/**
|
|
1147
|
+
* The request's session — set by the `session()` middleware, which must be
|
|
1148
|
+
* installed. Type your keys once by augmenting `SessionData`:
|
|
1149
|
+
*
|
|
1150
|
+
* ```ts
|
|
1151
|
+
* declare module '@forinda/kickjs' {
|
|
1152
|
+
* interface SessionData { userId?: string }
|
|
1153
|
+
* }
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
get session(): Session;
|
|
1194
1157
|
/**
|
|
1195
1158
|
* The authenticated user set by AuthAdapter.
|
|
1196
1159
|
* Reads from the per-request metadata store first (`ctx.set('user', ...)`),
|
|
@@ -1439,6 +1402,11 @@ TKeys extends ContextMetaKey = ContextMetaKey> implements ExecutionContext<TKeys
|
|
|
1439
1402
|
*/
|
|
1440
1403
|
redirect(url: string, status?: number): unknown;
|
|
1441
1404
|
html(content: string, status?: number): RuntimeResponse;
|
|
1405
|
+
/**
|
|
1406
|
+
* Send `buffer` as a file download named `filename`. The name is written
|
|
1407
|
+
* per RFC 6266 — an ASCII fallback plus `filename*` in UTF-8 — so a name
|
|
1408
|
+
* from an upload (quotes, line breaks, non-Latin text) can't break the header.
|
|
1409
|
+
*/
|
|
1442
1410
|
download(buffer: Buffer, filename: string, contentType?: string): RuntimeResponse;
|
|
1443
1411
|
/**
|
|
1444
1412
|
* Render a template using the registered view engine (EJS, Pug, Handlebars, etc.).
|
|
@@ -1527,6 +1495,14 @@ TKeys extends ContextMetaKey = ContextMetaKey> implements ExecutionContext<TKeys
|
|
|
1527
1495
|
* ```
|
|
1528
1496
|
*/
|
|
1529
1497
|
sendResponse(response: Response): Promise<void>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Keep `promise` running after the response is sent — an audit log, an
|
|
1500
|
+
* email, an analytics call. The Node server's `shutdown()` waits for it;
|
|
1501
|
+
* `createHandler()` and the web entry hand it to the platform's
|
|
1502
|
+
* `waitUntil` when you pass the platform context in. A rejection is
|
|
1503
|
+
* logged, never unhandled. Same as the standalone `waitUntil()` export.
|
|
1504
|
+
*/
|
|
1505
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
1530
1506
|
sse<T = unknown>(): SseHandler<T>;
|
|
1531
1507
|
}
|
|
1532
1508
|
/**
|
|
@@ -1591,6 +1567,8 @@ type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends
|
|
|
1591
1567
|
declare global {
|
|
1592
1568
|
namespace KickRoutes {}
|
|
1593
1569
|
}
|
|
1570
|
+
/** `attachment; filename="…"; filename*=UTF-8''…` for any file name (RFC 6266 / RFC 8187). */
|
|
1571
|
+
declare function contentDisposition(filename: string): string;
|
|
1594
1572
|
//#endregion
|
|
1595
1573
|
//#region src/http/runtime.d.ts
|
|
1596
1574
|
/** HTTP verbs the router emits. Mirrors the decorator surface (@Get/@Post/...). */
|
|
@@ -1672,11 +1650,22 @@ interface RouteMeta {
|
|
|
1672
1650
|
* question. See `core/route-flag.ts`.
|
|
1673
1651
|
*/
|
|
1674
1652
|
flags?: RouteFlags;
|
|
1653
|
+
/**
|
|
1654
|
+
* The full mounted pattern (`/api/v1/users/:id`) — set by the Application
|
|
1655
|
+
* for controller routes. `path` is relative to the module mount.
|
|
1656
|
+
*/
|
|
1657
|
+
pattern?: string;
|
|
1675
1658
|
}
|
|
1676
1659
|
interface MatchedRoute {
|
|
1677
1660
|
method: RouteMethod;
|
|
1678
1661
|
/** Path as declared on the handler, e.g. `/:id`. */
|
|
1679
1662
|
path: string;
|
|
1663
|
+
/**
|
|
1664
|
+
* The full route pattern including the mount prefix and version, e.g.
|
|
1665
|
+
* `/api/v1/users/:id` — what metrics and spans should be keyed by. Falls
|
|
1666
|
+
* back to `path` for routes registered without a mount.
|
|
1667
|
+
*/
|
|
1668
|
+
pattern: string;
|
|
1680
1669
|
controller?: Constructor;
|
|
1681
1670
|
handlerName?: string;
|
|
1682
1671
|
/** Enabled flags only — see {@link RouteMeta.flags}. */
|
|
@@ -1781,6 +1770,13 @@ interface RuntimeCapabilities {
|
|
|
1781
1770
|
* false — it relies on the `express.json()` connect middleware.
|
|
1782
1771
|
*/
|
|
1783
1772
|
nativeBodyParsing: boolean;
|
|
1773
|
+
/**
|
|
1774
|
+
* The engine's `nodeHandler` works behind `node:http2` (the HTTP/2
|
|
1775
|
+
* compatibility API), so `server: { http2: true }` may use it. Fastify/h3:
|
|
1776
|
+
* true. Express: false — it does not run on that layer. Absent = false, so
|
|
1777
|
+
* custom runtimes opt in explicitly.
|
|
1778
|
+
*/
|
|
1779
|
+
http2?: boolean;
|
|
1784
1780
|
}
|
|
1785
1781
|
/**
|
|
1786
1782
|
* The engine driver. KickJS owns decorators → {@link RouteTable}, the
|
|
@@ -1904,6 +1900,8 @@ interface AdapterMiddleware {
|
|
|
1904
1900
|
* }
|
|
1905
1901
|
* ```
|
|
1906
1902
|
*/
|
|
1903
|
+
/** The Node server behind the app — see `ApplicationOptions.server`. */
|
|
1904
|
+
type KickServer = http.Server | https.Server | http2.Http2SecureServer;
|
|
1907
1905
|
interface AdapterContext {
|
|
1908
1906
|
/**
|
|
1909
1907
|
* Engine-agnostic HTTP surface — the supported way to add routes, mounts,
|
|
@@ -1932,8 +1930,13 @@ interface AdapterContext {
|
|
|
1932
1930
|
fetch(request: Request): Promise<Response>;
|
|
1933
1931
|
/** DI container */
|
|
1934
1932
|
container: Container;
|
|
1935
|
-
/**
|
|
1936
|
-
|
|
1933
|
+
/**
|
|
1934
|
+
* The Node server the app listens on — only available in afterStart. An
|
|
1935
|
+
* `http.Server` by default; an `https.Server` or `Http2SecureServer` when
|
|
1936
|
+
* `bootstrap({ server })` sets `tls` / `http2`. All three emit `upgrade`
|
|
1937
|
+
* for HTTP/1.1 clients, which is what WebSocket libraries attach to.
|
|
1938
|
+
*/
|
|
1939
|
+
server?: KickServer;
|
|
1937
1940
|
/** Current NODE_ENV value (default: 'development') */
|
|
1938
1941
|
env: string;
|
|
1939
1942
|
/** true when NODE_ENV === 'production' */
|
|
@@ -2058,6 +2061,19 @@ interface AppAdapter {
|
|
|
2058
2061
|
name: string;
|
|
2059
2062
|
status: 'up' | 'down';
|
|
2060
2063
|
}>;
|
|
2064
|
+
/**
|
|
2065
|
+
* Observe every error the app reports — request errors (any status; filter
|
|
2066
|
+
* on `info.status`), uncaught exceptions, unhandled rejections, failed
|
|
2067
|
+
* `waitUntil` work, failed queue jobs, and anything passed to
|
|
2068
|
+
* `reportError()`. Observe-only: the response is not yours to change, and a
|
|
2069
|
+
* throw here is logged and skipped. The place to wire Sentry & co.
|
|
2070
|
+
*/
|
|
2071
|
+
onError?(error: unknown, info: ErrorInfo): void | Promise<void>;
|
|
2072
|
+
/**
|
|
2073
|
+
* Observe every finished response — method, path, the matched route
|
|
2074
|
+
* pattern, status, duration. Only timed while something listens.
|
|
2075
|
+
*/
|
|
2076
|
+
onResponse?(info: ResponseInfo): void | Promise<void>;
|
|
2061
2077
|
/**
|
|
2062
2078
|
* Called on shutdown — release what this adapter owns.
|
|
2063
2079
|
*
|
|
@@ -2102,5 +2118,5 @@ interface AppAdapter {
|
|
|
2102
2118
|
/** Constructor type for AppAdapter classes */
|
|
2103
2119
|
type AppAdapterClass = new () => AppAdapter;
|
|
2104
2120
|
//#endregion
|
|
2105
|
-
export {
|
|
2106
|
-
//# sourceMappingURL=adapter-
|
|
2121
|
+
export { setInMetaRecord as $, contentDisposition as A, SourcedRegistration as B, RuntimeTypeMap as C, reportResponse as Ct, RequestContext as D, DeepReadonly as E, RunContributorsOptions as F, getMetaRecord as G, getClassMeta as H, runContributors as I, hasClassMeta as J, getMethodMeta as K, BuildPipelineOptions as L, AdapterFactory as M, DefineAdapterOptions as N, RouteShape as O, defineAdapter as P, setInMetaMap as Q, ContributorPipeline as R, RuntimeResponse as S, reportError as St, Ctx as T, getClassMetaOrUndefined as U, buildPipeline as V, getMetaMap as W, pushMethodMeta as X, pushClassMeta as Y, setClassMeta as Z, RouteMeta as _, IntrospectionKind as _t, KickServer as a, defineModule as at, RuntimeAppOptions as b, ErrorSource as bt, ActiveRuntime as c, PluginAsyncOptions as ct, CtxHandler as d, KickPlugin as dt, setMethodMeta as et, ExpressRuntimeTypes as f, ModuleRegistry as ft, RouteEntry as g, IntrospectFn as gt, MatchedRoute as h, KickJsPluginRegistry as ht, AppAdapterClass as i, ModuleFactory as it, AdapterAsyncOptions as j, SseHandler as k, AdapterHttp as l, PluginFactory as lt, KickRuntimeRegister as m, KickJsPluginName as mt, AdapterMiddleware as n, defineModules as nt, MiddlewarePath as o, BuildContext as ot, HttpRuntime as p, MutableModuleRegistry as pt, getMethodMetaOrUndefined as q, AppAdapter as r, DefineModuleOptions as rt, MiddlewarePhase as s, DefinePluginOptions as st, AdapterContext as t, ModuleList as tt, ConnectMiddleware as u, definePlugin as ut, RouteMethod as v, IntrospectionSnapshot as vt, UseConnectOptions as w, RuntimeCapabilities as x, ResponseInfo as xt, RouteTable as y, ErrorInfo as yt, ContributorSource as z };
|
|
2122
|
+
//# sourceMappingURL=adapter-DhjoIYVI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-DhjoIYVI.d.mts","names":[],"sources":["../src/core/observers.ts","../src/core/introspect.ts","../src/core/augmentation.ts","../src/core/module-registry.ts","../src/core/plugin.ts","../src/core/define-plugin.ts","../src/core/define-module.ts","../src/core/define-modules.ts","../src/core/metadata.ts","../src/core/contributor-pipeline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