@sodacore/core
Provides the Application
runtime, lifecycle hooks, script runner, threads/workers helpers, and the decorator/metadata glue that other packages (HTTP, WS, etc.) lean on.
Quick look
ts
import { Application } from '@sodacore/core';
const app = new Application({
autowire: true,
});
app.start().catch(console.error);
Import surface (what you can use)
You import everything below from @sodacore/core
unless noted.
Runtime & modules
Application
— main entry point & lifecycle managerAutowire
— internal discovery module (usually not used directly)Events
— internal events dispatch (see@On
below)Services
— runs annotated services on schedule / startupRunner
/Scripts
— script registry & executorWorkers
,WorkerWrapper
— worker manager & per-worker helpers
Base classes (extend these)
BaseModule
— shared module features (logging, registry helpers)BasePlugin
— implement a plugin (name, version,dependencies
)BaseService
— long-running or scheduled logicBaseTask
— discrete unit of work (script/task)BaseWorker
— convenience wrapper for Node workers
Contexts
ScriptContext
— I/O helpers for scripts (prompting, logging, sessions)ThreadContext
— metadata passed into threads
Providers (ready-made)
Logger
— application loggerTasksProvider
— register/lookup tasksThreadsProvider
/WorkersProvider
— manage lifecycles for threads/workers
Decorators (core glue)
@Hook('init' | 'start' | 'stop')
— lifecycle hooks@Script('key')
— register a script@Task('key', options?)
— register a task@Thread(name?, options?)
/@Worker(name?, options?)
— mark thread/worker providers@Service(options?)
— mark a service provider@Autoload(glob | options)
— auto-import modules for discovery@Configure(schemaOrFn)
— attach/validate configuration for a module/plugin@Catch(mapper)
— map thrown errors to structured results.
Helpers
Constants
— common string constants / registry keysUtils
— small utility functionsWorkerUtils
— worker-related utilities
Selected types
IConfig
— Application config shape (top-level knobs; e.g.,http
,ws
)IPlugin
—{ name, version, dependencies? }
contract for pluginsILoggerType
— logger interface used byLogger
providerIHookType
—'init' | 'start' | 'stop'
Constructor<T>
— class ctor typeAsScript<T>
— narrows a class to a script runner interface
Available Scripts
In the packages/core
directory, you can run:
core:logs:watch
- Watches the logs directory and outputs to console.core:usage:info
- Outputs the current memory and CPU usage of the application.core:task:run
- Will ask you what task you want to run, and will run it.
Notes
All features are defined properly within the Concepts section of the docs.
If you need more specific API documentation, we highly suggest reading the code directly as it's all documented inline.