@kb-labs/rest-api-core
v1.0.0
Published
Core REST API functionality for KB Labs, including request handling and routing
Readme
@kb-labs/rest-api-core
Configuration loader and shared types for the KB Labs REST API runtime.
Overview
Provides the Zod schema, loader, and environment variable mapping for @kb-labs/rest-api-app.
No business logic — pure configuration infrastructure.
API Reference
loadRestApiConfig(options)— load and validate REST API config fromkb-labs.config.jsonrestApiConfigSchema— Zod schema for REST API configurationRestApiConfig— TypeScript type for validated config
Configuration
Loaded from kb-labs.config.json under the restApi key:
{
"restApi": {
"port": 5050,
"basePath": "/api/v1",
"apiVersion": "1.0.0",
"cors": {
"origins": ["http://localhost:3000"],
"profile": "dev"
},
"http2": {
"enabled": false,
"allowHTTP1": true
}
}
}Environment variables (KB_REST_*) override file config — see root README.md for full list.
HTTP/2
Enable HTTP/2 to remove the 6-connection browser limit (important for SSE):
{
"restApi": {
"http2": { "enabled": true, "allowHTTP1": true },
"ssl": { "keyPath": "ssl/server.key", "certPath": "ssl/server.cert" }
}
}Generate a self-signed cert for local development:
mkdir -p ssl
openssl req -x509 -newkey rsa:2048 -nodes \
-keyout ssl/server.key -out ssl/server.cert \
-days 365 -subj "/CN=localhost"Usage
import { loadRestApiConfig } from '@kb-labs/rest-api-core';
const config = await loadRestApiConfig({ cwd: process.cwd() });License
KB Public License v1.1 © KB Labs
