由 Temi O. 出售

Kottster is a self-hosted Node.js admin panel that lets you create pages to view and manage database tables, compose dashboards, and build fully custom pages. Secure, easy to set up, and deployable anywhere.
@kottster/server is the Node.js backend framework for Kottster, a self-hosted admin panel that connects to your database and serves a management UI. It provides factories, adapters, services, and error types for wiring up an Express-compatible server with data sources, identity providers, and RPC-style actions. The typical buyer is a backend engineer embedding an admin panel into an existing Node.js monorepo or standalone service.
lib/ - All TypeScript source for the frameworklib/index.ts - Public barrel export; the only file you should import fromlib/actions/ - Built-in server actions (login, CRUD on pages/users/roles, data source management, etc.)lib/adapters/knex/ - Knex-based database adapters for PostgreSQL, MySQL2, SQLite, and SQL Server (Tedious)lib/constants/ - Shared constants: common HTTP headers, error codes, project directory helperslib/core/ - Core runtime classes: App, Server, DataSourceRegistry, IdentityProvider, ExternalIdentityProviderlib/errors/ - Typed error classes: HttpError, ProcedureError, ValidationErrorlib/factories/ - Factory functions: createApp, createDataSource, createServer, createIdentityProviderlib/models/ - TypeScript interfaces for actions, adapters, error codes, procedureslib/services/ - Internal services: caching, debug logging, file I/O, storage, Kottster API client, exporterlib/utils/ - Utility helpers: name conversion, user sanitizationlib/version.ts - Exposes the package version stringlib/apiReference.ts - API surface descriptor used by the Kottster CLI and UIeslint.config.js - ESLint configuration (TypeScript-aware)jest.config.js - Jest configuration using ts-jesttsconfig.json - TypeScript compiler optionspackage.json - Package metadata and scriptsnpm install express knex
# Choose only the database driver(s) you need:
npm install pg # KnexPgAdapter (PostgreSQL)
npm install mysql2 # KnexMysql2Adapter (MySQL/MariaDB)
npm install better-sqlite3 # KnexBetterSqlite3Adapter (SQLite)
npm install tedious # KnexTediousAdapter (SQL Server)
启动隔离沙箱并在服务器端直接运行 — 无需本地配置。
此版本的 Tetrees AI Review
This Express backend / api completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
管道 avcp-2026-08-04.1 · SHA-256 cae8c4610cb241c2…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
审查日期 2026年8月4日
将此产品直接导入你的 AI IDE、网页构建器或云端 IDE。
将 Tetrees 连接到兼容的 AI IDE,列出你拥有的产品并获取已验证 ZIP,同时不会开放卖家上传权限。
暂无评价。
Sign in to join the discussion
Loading discussion…
No native iOS/Android build steps are required. If you use better-sqlite3, ensure your Node.js version matches the pre-built binary; rebuild with npm rebuild better-sqlite3 if you encounter binding errors.
Copy source. Place the contents of source/ (i.e., the packages/server directory) into your project, for example at vendor/kottster-server/.
Configure TypeScript paths. In your root tsconfig.json, add a path alias so imports resolve cleanly:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@kottster/server": ["vendor/kottster-server/lib/index.ts"]
},
"module": "CommonJS",
"target": "ES2020",
"strict": true
}
}
APP_SECRET=your-random-secret-32-chars-minimum
NODE_ENV=development # or production
PORT=5480 # optional, defaults vary
Wire the entry point. Create src/index.ts (see examples below) that calls createApp, createDataSource, and createServer, then starts listening.
Build. Use tsc or a bundler like esbuild. The source is plain TypeScript with no special JSX transforms needed.
import { createApp } from '@kottster/server';
function createApp(options: { secretKey: string }): App
Instantiates the core App object that holds application-level configuration and state. Pass your APP_SECRET as secretKey. This must be called before creating a server or registering data sources.
import { createDataSource } from '@kottster/server';
function createDataSource(options: {
type: string;
adapter: DataSourceAdapter;
}): DataSource
Wraps a Knex adapter into a data source object the app registry can consume. Call once per database connection and register it via the server setup. Use the appropriate Knex*Adapter exported from the same package.
import { createServer } from '@kottster/server';
function createServer(app: App, options?: ServerOptions): Server
Builds the HTTP server (Express under the hood) with all built-in Kottster routes pre-registered. Returns a Server instance you call .listen() on. Accepts an optional options object for port and middleware configuration.
import { createIdentityProvider } from '@kottster/server';
function createIdentityProvider(input: ExternalIdentityProviderInput): IdentityProvider
Creates an identity provider for authentication. Use this when you want to delegate auth to an external provider rather than the built-in Kottster user store.
import { ProcedureError } from '@kottster/server';
class ProcedureError extends Error {
constructor(message: string, code?: string)
}
Throw inside custom procedure handlers to signal a user-facing error. The server catches it and serializes it into a structured error response instead of a 500.
import { ValidationError } from '@kottster/server';
class ValidationError extends Error {
constructor(message: string, fields?: Record<string, string>)
}
Throw when input validation fails inside a procedure. Carries per-field error metadata that the Kottster UI can display inline on forms.
import { CachingService } from '@kottster/server';
class CachingService {
set(key: string, value: any, ttlSeconds?: number): void
get<T>(key: string): T | undefined
invalidate(key: string): void
}
In-process TTL cache. Use it inside custom actions or procedures to avoid redundant database round-trips. Instantiate once and share across handlers.
Bootstrap a Kottster admin panel backed by a PostgreSQL database. This is the most common starting point.
import { createApp, createDataSource, createServer, KnexPgAdapter } from '@kottster/server';
const app = createApp({
secretKey: process.env.APP_SECRET ?? 'change-me-in-production',
});
const pgDataSource = createDataSource({
type: 'postgres',
adapter: new KnexPgAdapter({
client: 'pg',
connection: {
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT ?? 5432),
database: process.env.DB_NAME ?? 'mydb',
user: process.env.DB_USER ?? 'postgres',
password: process.env.DB_PASSWORD ?? '',
},
}),
});
const server = createServer(app);
server.registerDataSource(pgDataSource);
server.listen(5480, () => {
console.log('Kottster admin running on http://localhost:5480');
});
Show how to signal validation and procedure failures in a way the Kottster UI understands.
import { ProcedureError, ValidationError, CachingService } from '@kottster/server';
const cache = new CachingService();
async function fetchUserById(id: number) {
const cached = cache.get<{ name: string }>(`user:${id}`);
if (cached) return cached;
if (!id || id <= 0) {
throw new ValidationError('Invalid input', { id: 'Must be a positive integer' });
}
const user = await db('users').where({ id }).first();
if (!user) {
throw new ProcedureError(`User with id ${id} not found`, 'USER_NOT_FOUND');
}
cache.set(`user:${id}`, user, 60);
return user;
}
Wire up a local SQLite database for rapid local development without a running database server.
import {
createApp,
createDataSource,
createServer,
KnexBetterSqlite3Adapter,
} from '@kottster/server';
import path from 'path';
const app = createApp({
secretKey: process.env.APP_SECRET ?? 'dev-secret-key-do-not-use-in-prod',
});
const sqliteDataSource = createDataSource({
type: 'sqlite',
adapter: new KnexBetterSqlite3Adapter({
client: 'better-sqlite3',
connection: {
filename: path.resolve(__dirname, '../data/local.sqlite'),
},
useNullAsDefault: true,
}),
});
const server = createServer(app);
server.registerDataSource(sqliteDataSource);
server.listen(5480);
lib/index.ts - Public barrel; the only import surface for consumers.lib/version.ts - Exports the current package version string; used by the CLI and API.lib/apiReference.ts - Describes the full API surface for introspection by Kottster tooling.lib/actions/ - One file per server action (e.g., login, createPage, addDataSource); each action is a discrete async handler invoked by the RPC router.lib/adapters/knex/ - Thin wrappers that normalize Knex client configurations for each supported database driver.lib/constants/ - Frozen values: HTTP header names, error code strings, resolved project directory paths.lib/core/app.ts - App class: holds secret key and app-level state.lib/core/server.ts - Server class: Express app factory with Kottster routes mounted.lib/core/dataSourceRegistry.ts - Registry that maps named data sources to their adapters at runtime.lib/core/identityProvider.ts - Built-in identity provider handling JWT issuance and session validation.lib/core/externalIdentityProvider.ts - Delegate interface for OAuth/SSO integration.lib/errors/httpError.ts - Generic HTTP error with status code; used internally by the router.lib/errors/procedureError.ts - User-facing procedure failure; caught and serialized by the server.lib/errors/validationError.ts - Field-level validation failure with metadata map.lib/factories/ - Pure factory functions (createApp, createServer, createDataSource, createIdentityProvider) that are the recommended construction path.lib/models/ - TypeScript interfaces for action, adapter, error code, and procedure contracts.lib/services/caching.service.ts - In-process TTL key/value store.lib/services/debugLogger.service.ts - Conditional debug output gated on NODE_ENV.lib/services/fileReader.service.ts / fileWriter.service.ts - Read/write project config files from disk.lib/services/kottsterApi.service.ts - HTTP client for the Kottster cloud API (schema sync, licensing).lib/services/storage.service.ts - Persistent key/value storage backed by the project directory.lib/services/exporter.service.ts - Serializes app schema and data for export.lib/services/action.service.ts - Dispatches named actions to their handler functions.lib/utils/convertName.ts - Converts identifiers between camelCase, snake_case, etc.lib/utils/prepareUserForClient.ts - Strips sensitive fields from user objects before sending to the UI.APP_SECRET too short or missing. The framework will reject startup or produce weak tokens. Fix: set a random 32+ character string in your environment before running.better-sqlite3 native binding mismatch. After Node.js upgrades the prebuilt binary breaks. Fix: run npm rebuild better-sqlite3 inside your project.tsc strips path aliases; the compiled JS still has them. Fix: use tsconfig-paths (node -r tsconfig-paths/register dist/index.js) or esbuild which resolves aliases at bundle time.knex. Some Knex versions ship ESM-only sub-paths. Fix: set "module": "CommonJS" in tsconfig.json and use require-compatible Knex imports.PORT=<other> and pass it explicitly to server.listen().ProcedureError not caught as structured response. Throwing a plain Error instead of ProcedureError causes the server to return a generic 500. Fix: always import and throw ProcedureError or ValidationError from @kottster/server.I have copied the Kottster Server source into `vendor/kottster-server/` in my project.
I also have USAGE.md in the same directory as this prompt.
Please integrate Kottster Server into my existing Node.js/TypeScript project by:
1. Reading USAGE.md and `vendor/kottster-server/lib/index.ts` to understand the public API.
2. Adding a TypeScript path alias `@kottster/server` → `vendor/kottster-server/lib/index.ts` in my tsconfig.json.
3. Creating `src/admin.ts` that:
- Calls `createApp` with my APP_SECRET env var.
- Calls `createDataSource` with the appropriate Knex adapter for my database (ask me which one).
- Calls `createServer`, registers the data source, and starts listening on PORT env var.
4. Ensuring all imports use the real exported symbols from `lib/index.ts` only.
5. Adding `tsconfig-paths` to dev dependencies and updating my start script if needed.
6. Pointing out any missing peer dependencies for my chosen database driver.
Ask me for my database type and connection details before generating code.
Reference package: @kottster/server (upstream: kottster/kottster, packages/server).
Kottster is licensed under the Apache License 2.0. Source and full license text are available at https://github.com/kottster/kottster. The upstream npm package is @kottster/server.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
完整安装指南与集成提示词将在购买后解锁。
CRM, ERP, Admin & Internal Tools
免费