Skip to main content

kickjs-thin-entry-file

Use when src/index.ts is accumulating module/middleware/plugin/adapter literals.

来源信息

仓库
forinda/kick-fullstack-netlify
最近来源活动
2026年9月18日 11:52
检测到的 SKILL.md 语言
英语
星标
0
Forks
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
kickjs-thin-entry-file
description
Use when src/index.ts is accumulating module/middleware/plugin/adapter literals.
<!-- Generated by `kick g agents` for kick-fullstack. Edits are overwritten on the next refresh; keep customisation in a SKILL.local.md alongside. --> **Refactor target**: ```ts // src/modules/index.ts — fluent chain (default for `modules.style: 'define'`) export const modules = defineModules().mount(HelloModule()).mount(UsersModule()) // OR for class-form projects (`modules.style: 'class'`): // export const modules: AppModuleEntry[] = [HelloModule, UsersModule] // src/middleware/index.ts — global middleware uses RAW EXPRESS signature // (req, res, next), NOT (ctx, next) // `express.json()` is auto-skipped on Fastify and h3, which parse bodies // natively — harmless to list, but don't reach for it as the body parser there. export const middleware = [requestId(), express.json(), helmet(), cors(), traceContext()] // src/plugins/index.ts export const plugins = [MetricsPlugin(), AuthPlugin({ tokenTtl: env.TOKEN_TTL })] // src/adapters/index.ts export const adapters = [SwaggerAdapter({ ... }), DevToolsAdapter()] // src/index.ts — stays small import 'reflect-metadata' import './config' // MUST be early — side-effect schema load import { bootstrap } from '@forinda/kickjs' import { modules } from './modules' import { middleware } from './middleware' import { plugins } from './plugins' import { adapters } from './adapters' export const app = await bootstrap({ modules, middlewares, plugins, adapters }) ``` **One-off DI binding** — inline a literal plugin inside `plugins`, not a top-level option: ```ts plugins: [ ...plugins, { name: 'vector-store', register(c) { c.registerInstance(VECTOR_STORE, store) } }, ] ``` **Red flags**: - Any `new SomeAdapter()` / `SomePlugin()` literal inside `bootstrap({ ... })` instead of imported from a category folder. - Mixing middleware signatures: `bootstrap({ middlewares })` is **raw Express** `(req, res, next)`; `@Middleware()` decorators are `(ctx, next)`; adapter middleware is connect-style too (mounted through the runtime seam, so it is not Express-only). Wrong shape in the wrong slot throws "Cannot read properties of undefined". - `bootstrap({ register: ... })` — that option doesn't exist. Use an inline plugin.
在 GitHub 查看