@appneurox/service-runtime

中文文档
0.1.0发布于 2026/10/27Apache-2.0TypeScriptCommonJS近 30 天下载 2632

Shared NestJS container baseline; catalogue business capabilities remain explicitly unimplemented.

原始使用文档
文档目录5 节
  1. Standalone entry
  2. Settings
  3. Endpoints
  4. Extend a service
  5. Verification

Shared NestJS container baseline

@appneurox/service-runtime is the common HTTP foundation for catalogue service repositories. It starts one Node 24 process on port 8080; run as a nonroot user in the deployment container. The hosting edge terminates HTTPS. This package does not implement catalogue business operations, proxy existing backends, provision databases, or claim provider readiness.

Public responses label the deployment runtime: "BOILERPLATE", businessImplementation: "not_implemented", and businessReady: false. /health/ready measures HTTP bootstrap and drain state only. /health/business returns 501. Capability metadata always forces implementation: "not_implemented", even if a supplied file requests a different status.

Standalone entry

Build and test on the remote runner, without local Docker or dependency installation:

npm ci --ignore-scripts
npm test
SERVICE_NAME=example-service SERVICE_CAPABILITY_LABEL="Example capability" node dist/main.js

npm ci uses the committed lockfile. Do not publish credentials in repository files, CI output, images, or capability metadata. Runtime credentials belong in platform secrets. The package is private and is vendored into each service repository as .platform/nestjs/.

Repository root invocation after installing/building this package remotely:

node .platform/nestjs/dist/main.js

Settings

SettingDefault and validation
SERVICE_NAMERequired lowercase kebab slug, for example example-service
SERVICE_CAPABILITY_LABELDisplay label; defaults to the service name
CATALOG_SLUGService name with a trailing -service removed
SERVICE_VERSION0.1.0-boilerplate
BUILD_SHAunknown; otherwise 7–64 hexadecimal characters
NODE_ENVproduction; also accepts development, test
PORT, HOST8080, 0.0.0.0; explicit loopback/IPv6 bind addresses also accepted
MAX_BODY_BYTES65536; range 1024–1048576; compressed JSON is rejected
REQUEST_TIMEOUT_MS15000; range 1000–60000; bounds headers and socket inactivity
SHUTDOWN_TIMEOUT_MS20000; range 1000–60000
LOG_LEVELinfo; debug, warn, error, silent also accepted
CORS_ORIGINSEmpty; otherwise comma-separated exact HTTPS origins, no wildcard or credentials
EXISTING_BACKEND_URLOptional HTTPS reference only, without userinfo, query or fragment
SERVICE_METADATA_FILEOptional UTF-8 JSON file, at most 64 KiB
SERVICE_CAPABILITIES_JSONAlternative inline metadata JSON; mutually exclusive with the file

Metadata file format, containing public product information only:

{
  "capabilities": [
    { "id": "example-operation", "name": "Example operation", "description": "Planned business capability." }
  ]
}

Without a file or inline JSON, the package exposes one pending capability from CATALOG_SLUG and SERVICE_CAPABILITY_LABEL. Maximum 500 capability entries; duplicate IDs and invalid names fail startup. Invalid settings report setting names, never supplied values.

Endpoints

PathMeaning
/Service identity and explicit boilerplate disclosure
/versionVersion/build identity and pending business status
/health/liveProcess can answer HTTP
/health/readyHTTP runtime initialized and not draining, 200/503
/health/businessBusiness capability unimplemented, 501
/v1/capabilitiesPlanned capabilities and common baseline metadata

All other registered controllers require verified authentication unless explicitly annotated @Public(). Unregistered paths return a normalized 404. The baseline never interprets any shared token, a tenant header, a decoded JWT, or a frontend session as verified identity.

Extend a service

import { bootstrapService, RequireScopes, RequireTenant } from '@appneurox/service-runtime';
import type { AuthVerifier } from '@appneurox/service-runtime';
import { RecordsModule } from './records/records.module';

// Implement this port using the actual identity authority. Verify signature,
// issuer, audience and expiry; resolve membership/scopes. Invalid token -> null.
// Provider/authority outage -> throw. No reference verifier is fabricated here.
declare const verifier: AuthVerifier;

void bootstrapService({ imports: [RecordsModule], authVerifier: verifier });

Use @RequireTenant() and @RequireScopes('records:read') on protected routes. X-Tenant-ID is an untrusted selection until the guard confirms membership in the verified principal's tenantIds; no tenant header creates authority. A principal with exactly one tenant may select it implicitly; multiple tenants require selection on tenant-required routes. Scopes match exactly, with no automatic wildcard escalation. The verifier receives the raw bearer token privately and must not log it. Protected routes return 401 without credentials, 503 when no verifier is configured, and 403 for mismatched membership/scopes.

CurrentPrincipal, CurrentTenant, requestContext, and SERVICE_CONFIG are exported for business code. Scope every repository query/write to the authenticated tenant; this HTTP contract does not substitute for database isolation or resource authorization. Business modules must implement their real dependency probes, OpenAPI contracts, storage/migrations, transactions/idempotency, provider integrations, authorization, telemetry, and functional tests separately. Preserve existing business backends while adopting common code; this package is a starter, not an automatic migration.

createServiceApplication() initializes without listening or signal handlers for tests/embedding. bootstrapService() listens, handles SIGTERM/SIGINT, marks draining before close, and forces exit after the shutdown deadline. It returns { app, config, shutdown }; programmatic shutdown is idempotent. Use handleSignals: false when the host owns lifecycle handling.

Strict DTO validation uses class-validator metadata: unknown properties and implicit coercion are rejected, and validation values are excluded from responses. Request/correlation IDs propagate after syntax checks; duplicate security headers are rejected. Logs include method, route template, duration, status and IDs, excluding raw URLs, headers, bodies and queries. Security headers, disabled proxy-header trust, JSON limits and generic exceptions apply to every controller. Apply authentication-aware rate limits at the edge and/or a real shared store; this starter does not pretend an in-memory counter is a fleet-wide quota.

Verification

npm test compiles TypeScript then runs Node's test runner. Tests cover metadata honesty, configuration limits, redaction, public health semantics, auth default denial, tenant/scopes, request-local context, DTO rejection, malformed/oversize/compressed JSON, duplicate headers, security headers, CORS, and secret-free exceptions/logs. Dependency installation and executable tests are intentionally performed on the remote CI runner for this fleet.

版本与发布记录

@appneurox/service-runtime 共发布 2 个版本,首次发布于 2026/10/27;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/10/2712 天前
0.0.0-stage2026/10/2712 天前

关于 @appneurox/service-runtime 的常见问题

@appneurox/service-runtime 是什么?

Shared NestJS container baseline; catalogue business capabilities remain explicitly unimplemented.

如何安装 @appneurox/service-runtime?

在项目目录运行 npm install @appneurox/service-runtime,或使用 pnpm add / yarn add / bun add。

@appneurox/service-runtime 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@appneurox/service-runtime 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@appneurox/service-runtime 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24 <25。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@appneurox/service-runtime 可以商用吗?

@appneurox/service-runtime 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@appneurox/service-runtime 的下载量有多少?

根据 npm 官方下载统计,@appneurox/service-runtime 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,632 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appneurox/service-runtime 还在维护吗?

最新版本 0.1.0 发布于 2026/10/27(12 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/10/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。