@arche-cms/core
v0.1.5
Published
Foundation package for the Arche CMS framework. Provides dependency injection, event bus, lifecycle management, logging, and configuration loading.
Downloads
356
Readme
@arche-cms/core
Foundation package for the Arche CMS framework. Provides dependency injection, event bus, lifecycle management, logging, and configuration loading.
Installation
yarn add @arche-cms/coreExports
Container
Typed, async-capable dependency injection container.
import { Container } from "@arche-cms/core";
const container = new Container();
container.register("db", async () => new SQLiteAdapter("file:./db.sqlite"));
const db = await container.resolve("db");EventBus
Typed event bus with async middleware support.
import { EventBus } from "@arche-cms/core";
const bus = new EventBus();
bus.on("user:created", async (payload) => {
console.log("User created:", payload.email);
});
bus.emit("user:created", { email: "[email protected]" });Lifecycle
Manages application lifecycle states (init, ready, shutdown).
import { Lifecycle } from "@arche-cms/core";
const lifecycle = new Lifecycle();
lifecycle.onShutdown(async () => {
await db.disconnect();
});createLogger
Creates a structured logger instance.
import { createLogger } from "@arche-cms/core";
const logger = createLogger({ level: "info" });
logger.info("Server started", { port: 3000 });createConfigLoader
Loads configuration from environment variables, files, and defaults.
import { createConfigLoader } from "@arche-cms/core";
const loader = createConfigLoader({ prefix: "CMS_" });
const config = loader.load();