You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 311e2eb
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: extract @vitnode/api and migrate API scaffolding
Move the VitNode backend out of @vitnode/core into a new publishable
workspace package, packages/api (@vitnode/api), with one dependency
direction: core depends on api, never the reverse.
- api owns src/api (flattened), the database schema and drizzle.config,
content/server and the server halves of access/approvals/containers,
emails, API locales, WebSocket/Cloudflare runtimes, the page-cache
store/protocol and the vitnode CLI (bin), plus the browser-safe
contracts both sides read (content definitions, staff permissions,
fetcher contract/registry, plugin manifest, widget schemas).
- Split mixed modules: VitNodeApiConfig/buildApiConfig move to
@vitnode/api/vitnode.config; widgets split into API schemas
(defineWidgetSchema) and core renderers (defineWidget) with separate
default registries; i18n sources, editable pages and dashboard widget
types split along the same line.
- The CLI loads frontend route checks from core's
`frontendCliIntegration` export when the project has core, and skips
them otherwise; an older core without the export is reported, not
mistaken for an API-only project.
- The built-in plugin keeps the logical id @vitnode/core: endpoints,
fetcher calls, permissions, events and database rows are unchanged.
Drizzle discovers built-in tables in @vitnode/api; checkPluginId and
the update feed map the built-in id to the package that ships it
(one API_PACKAGE constant beside CORE_PLUGIN_ID).
- Migrate apps, plugins, adapters, create-vitnode-app modes and
templates, plugin registration, turbo.json, the publish workflow,
version manager, update-manifest publisher, docs and AGENTS.md.
- Trim dependencies: `shadcn` to core devDependencies; drop
`@hono/zod-validator`, core's leftover `drizzle-kit`/`jsdom`/`tsx`,
duplicate `jiti`/`motion` entries and the `@hono/zod-openapi` peer;
declare `sonner`/`lucide-react` peers and optional `tailwindcss`/
`tw-animate-css` peers.
- Remove every `sql.raw` call: keyset and thread cursors cast their
text back with `cursorTextCast`, the comparison picks `>`/`<` with
tagged templates, and the search vector CASE and SSO CHECK lists use
`sql` fragments with `.inlineParams()`. Generated SQL and DDL are
unchanged.
- Upgrade pnpm to 12.21.0 across workflows and docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ Pick the error view by what failed:
85
85
86
86
-`fetcher` from `@vitnode/core/tanstack/fetcher` is universal - one call, SSR and browser. Never hand-write `createIsomorphicFn().server(...).client(...)` for a fetch.
87
87
- A call names the plugin, never an API module: `fetcher({ plugin: "@vitnode/core", method: "get", module: "users", path: "/devices" })`. `plugin`, `module` (any nesting depth, `admin/advanced/cron`), `path`, `method`, `args` and the response are all inferred from the plugin API registry; an invalid combination is a compile error at the offending property.
88
-
- The registry is `ApiPluginRegistry` in `@vitnode/core/lib/fetcher/registry`. Core registers itself; an app's `src/api-registry.gen.ts` registers every configured plugin that exports `config.api`, with type-only imports; `vitnode build`/`vitnode dev` write a plugin's own entry to its `types/api-registry.gen.d.ts` (kept out of the published package) so its pages can call it. Never import a plugin API factory as a value outside `vitnode.api.config.ts`.
88
+
- The registry is `ApiPluginRegistry` in `@vitnode/api/lib/fetcher/registry` (`@vitnode/core/lib/fetcher/registry` re-exports it). Core registers itself; an app's `src/api-registry.gen.ts` registers every configured plugin that exports `config.api`, with type-only imports; `vitnode build`/`vitnode dev` write a plugin's own entry to its `types/api-registry.gen.d.ts` (kept out of the published package) so its pages can call it. Never import a plugin API factory as a value outside `vitnode.api.config.ts`.
89
89
-`@vitnode/core/tanstack/fetcher/server` is for work that is genuinely server-only: server functions, `allowSaveCookies` cookie relay, cron/jobs, upstream secrets or a different `origin`. Same call shape, more options.
90
90
- Shared `views/*` query modules call `fetcher` directly - no injected transport, no browser-only twin. `@vitnode/core/lib/fetcher-client` is the framework-neutral browser primitive the universal fetcher is built on, for code that never renders on a server.
91
91
- Write the route inline at the call site - never build a request object elsewhere and pass it in.
@@ -101,6 +101,12 @@ Pick the error view by what failed:
101
101
- Content Engine tag builders live in `content/cache.ts` (`contentPublicListTag` and friends) - pure strings, used to expire a content type's cached reads.
102
102
- A background mutation cannot expire a front end's cache by calling a function. `dispatchContentRevalidation` posts to the origins an install opts into via `content.revalidateOrigins`.
103
103
104
+
# Packages
105
+
106
+
-`@vitnode/api` (`packages/api`) owns the backend: Hono API, database schema, Content Engine server, emails, WebSocket/Cloudflare runtime and the `vitnode` CLI. `@vitnode/core` (`packages/vitnode`) owns React, the AdminCP, TanStack Start and the Vite plugin, and depends on `@vitnode/api` - never the other way round, not even for types.
107
+
- Server code imports from `@vitnode/api/...` (`@vitnode/api/lib/plugin`, `@vitnode/api/database/*`, `@vitnode/api/content/server`, `buildApiConfig` from `@vitnode/api/vitnode.config`). Contracts both sides read (content definitions, staff permissions, widget schemas) live in browser-safe `@vitnode/api` subpaths; core imports them directly, not through its own re-export stubs.
108
+
- The built-in plugin keeps the logical id `@vitnode/core` in endpoints, `fetcher({ plugin: "@vitnode/core" })`, permissions, events and database rows. Never replace that id with the package name.
109
+
104
110
# Coding Guidelines
105
111
106
112
- Always implement best practices for performance, security, and accessibility.
@@ -188,7 +194,7 @@ npm i x
188
194
### Speed
189
195
190
196
- The file name picks the environment: `*.test.tsx` runs in happy-dom (project `dom`), `*.test.ts` runs in node (project `unit`). Never add a `// @vitest-environment` pragma.
191
-
-`unit` shares one module graph per worker (`isolate: false`). A test that asserts process-wide state ("nothing registered yet") goes in `ISOLATED` in `packages/vitnode/vitest.config.ts`.
197
+
-`unit` shares one module graph per worker (`isolate: false`). A test that asserts process-wide state ("nothing registered yet") goes in `ISOLATED` in the package's `vitest.config.ts` (`packages/vitnode` or `packages/api`).
192
198
- Real builds, watchers and child processes go in `INTEGRATION` there. `pnpm test` runs everything; `pnpm test:unit` skips them.
193
199
- Never wait out a real delay - use `vi.useFakeTimers()` and advance the clock.
194
200
- Build a Hono app or a fixture once per file when the tests only read from it.
0 commit comments