@rapidrest/core
v5.1.0
Published
A collection of common utilities and core functionality for rapidly building RESTful applications.
Readme
RapidREST: Core Library
A shared utility library consumed by RapidREST-based applications and servers, including
@rapidrest/service-core. It provides the
foundational building blocks — dependency injection, caching, messaging, logging, token-based auth
and more — that the rest of the RapidREST ecosystem is built on.
For complete documentation please visit RapidREST.dev.
Features
Object Lifecycle & Dependency Injection
ClassLoader— dynamically discovers and loads classes at runtime from a folder structure, using C#/Java-style namespace conventionsObjectFactory— a lightweight DI container that creates and tracks classes and instances- Easily inject class dependencies via
@Inject,@Config,@Logger - Control object lifecycle via
@Init,@Destroy
Caching & Session Storage
- A common
SimpleStoreinterface for TTL-based record storage, withMemoryStore(in-process) andRedisStore(Redis-backed, for sharing state across multiple app instances) implementations - Bulk (
loadMany/saveMany) and named record-set (loadSet/saveSet) operations
Auth & Validation
JWTUtils— create, sign, verify and decode JSON Web Tokens, with optional password- or key-based payload encryption and compressionUserUtils— role, scope and organization-membership checks against authenticated user objectsValidationUtils— a library of common field validators (email, URL, phone, UUID, semantic version, IP address, date, JSON, etc.) for use with the@Validatordecorator
Messaging & Alerting
MessagingUtils— send templated (Handlebars) messages over e-mail, SMS or Slack from a shared template storeAlertUtils— send priority-based (P1–P5) incident alerts, with file attachments, to an external alerting/on-call serviceNotificationUtils— publish real-time push notifications over Redis pub/sub, to a single user's channel or broadcast to every subscriber
Observability
Logger— a pre-configured, cached Winston logger that automatically tags log lines with the calling class/method nameTelemetryUtils— record application telemetry events and forward them to a configured collection service
General Utilities
StringUtils— template variable substitution and other string helpersObjectUtils— deep property get/set, scoped-property scrubbing, and schema-driven object validationFileUtils— file/directory existence checks, copying and reads, with optional root-directory containmentOASUtils— load, cache and query OpenAPI (Swagger) specifications from a local file or URL (JSON or YAML), with opt-in path/host allow-listingCacheUtils— shared helpers for bounded, eviction-on-insertMap-based cachesApiError— an HTTP-awareErrorsubclass carrying an error code, HTTP status, and templated messages
Concurrency
ThreadPool— manage a pool of Node.js worker threads (auto-sized to the number of CPUs by default), with typed message passing and automatic restart on worker crash
Getting Started
Yarn
yarn add @rapidrest/coreNPM
npm i @rapidrest/coreRequirements
This package targets Node.js >=24.0.0 and is published as an ESM-only package.
The following peer dependencies are required:
| Peer dependency | Required for |
| ------------------- | ------------------------------------ |
| axios | Always |
| redis | Caching & sessions via RedisStore |
| reflect-metadata | Always |
| winston | Always |
| winston-transport | Always |
MessagingUtils dynamically imports the following packages at runtime, so they are not declared as
dependencies — only install the ones for the channel(s) you actually use:
| Package | Required for |
| ------------- | ------------------|
| nodemailer | E-mail messaging |
| twilio | SMS messaging |
| @slack/bolt | Slack messaging |
License
MPL v2.0 — see LICENSE.
