@deploybaseline/core
v0.14.0
Published
HTTP server, in-memory store, plugin interface, and middleware for Baseline service plugins.
Readme
@deploybaseline/core
HTTP server, in-memory store, plugin interface, and middleware for Baseline service plugins.
Part of Baseline — local drop-in replacement services for CI and no-network sandboxes.
The internal HTTP layer builds on Hono's API and design. Thank you to Yusuke Wada and the Hono contributors. See THIRD_PARTY_NOTICES.md for Hono's copyright and MIT license notice, also included in this npm package.
Install
npm install @deploybaseline/coreOverview
The core provides the shared infrastructure that every @deploybaseline/* service plugin builds on:
- Store — a generic in-memory store with typed
Collection<T>instances supporting CRUD, indexing, filtering, and pagination - Server — HTTP server with automatic port management;
servelistens on127.0.0.1by default and accepts an explicithostnamefor network access - Middleware — bearer token auth, error handling, CORS
- UI — shared authorization/consent page rendering with bundled fonts
- Persistence — pluggable save/load adapters for state durability
Persistence
A PersistenceAdapter is any object with load and save methods. filePersistence(path) is the built-in file adapter. Pass an adapter as state to createEmulator from @deploybaseline/cli:
import type { PersistenceAdapter } from '@deploybaseline/core'
const kvState: PersistenceAdapter = {
async load() { return await kv.get('baseline-state') },
async save(data) { await kv.set('baseline-state', data) },
}Custom emulators
Definitions created with defineEmulator from @deploybaseline/cli run through the CLI and through createEmulator({ service: definition }) in tests. Custom entries accept an optional inspector and persistence adapter. Streamed response bodies persist state changes on completion or cancellation, and reset and close cancel active streams before cleanup. Keep state inside the definition's state factory. See the custom emulator guide.
