alepha@docs:~/docs/packages/alepha$
cat core.md
2 min read
Last commit:

#Alepha - Core

Easy-to-use modern TypeScript framework for building many kind of applications.

#Installation

Part of the alepha package. Import from alepha.

npm install alepha

#Overview

Foundation of the entire framework with dependency injection and lifecycle management.

Features:

  • Dependency injection for services
  • Service substitution/mocking
  • Type-safe environment variable loading with TypeBox schemas
  • Lifecycle hooks (start, stop, log, etc.)
  • Module definitions and composition
  • Request-scoped context access via Async Local Storage (ALS)
  • Reactive state management with atoms
  • Cluster mode with automatic worker forking
  • Full TypeScript generics and type inference

#API Reference

#Primitives

  • $atom — Define an atom for state management.
  • $env — Get typed values from environment variables.
  • $hook — Registers a new hook.
  • $inject — Get the instance of the specified type from the context.
  • $memoize — Lightweight in-process memoization middleware.
  • $mode — * Environment variable to check for.
  • $module — Wrap Services and Primitives into a Module.
  • $pipeline — Creates a pipeline primitive that composes middleware with a handler.
  • $scope — Middleware that wraps the handler in an ALS (AsyncLocalStorage) context.
  • $use — Subscribes to an atom's state and returns its current value for use in components.

#Providers

  • CodecManager — CodecManager manages multiple codec formats and provides a unified interface
  • Json — Mimics the JSON global object with stringify and parse methods.
  • KeylessJsonSchemaCodec — KeylessJsonSchemaCodec provides schema-driven JSON encoding without keys.