npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@node-yalc/common

v0.3.8

Published

Common interfaces and abstractions for Yalc frameworks

Readme

npm version License

🚀 Installation

npm install @node-yalc/common
# or
yarn add @node-yalc/common
# or
pnpm add @node-yalc/common

Common Core Constants, Enumerations & Value Objects

The @node-yalc/common package provides enterprise-wide value objects, system constants, execution environment enumerations, HTTP status code maps, and shared microservice metadata contracts used across the entire YALC suite.


1. What It Is & Architectural Purpose

In microservice monorepos, shared primitives like environment flags (NODE_ENV), currency codes, execution status strings, standard date formats, and HTTP header names often end up hardcoded across multiple repositories. This duplication causes inconsistencies - such as one service expecting "prod" while another checks "production".

@node-yalc/common centralizes these foundational constants and value objects into a single, zero-dependency package. It guarantees absolute consistency across backend Node.js microservices, NestJS applications, CLI tools, and serverless Lambda functions.

┌────────────────────────────────────────────────────────────────────────┐
│                          @node-yalc/common                             │
├────────────────────────────────────────────────────────────────────────┤
│  • System Environment Enums (AppEnv, NodeEnv)                         │
│  • Standard HttpHeaders & HttpMethod Maps                              │
│  • Value Objects (Money, Currency, IsoLanguage)                       │
│  • Monorepo Namespace Constants                                        │
└──────────────────────────────────┬─────────────────────────────────────┘
                                   │ Shared Primitives
            ┌──────────────────────┼──────────────────────┐
            ▼                      ▼                      ▼
┌──────────────────────┐┌──────────────────────┐┌──────────────────────┐
│ @node-yalc/logger    ││ @node-yalc/errors    ││ @node-yalc/utils     │
└──────────────────────┘└──────────────────────┘└──────────────────────┘

2. What It Does & Key Capabilities

  • AppEnvEnum & NodeEnvEnum: Type-safe enumerations (LOCAL, DEVELOPMENT, STAGING, PRODUCTION, TEST) with environment validation helpers.
  • HttpHeaders & HttpMediaTypes: Standardized string constants for HTTP headers (X-Correlation-Id, X-Request-Id, Authorization, Content-Type).
  • IsoCurrency & IsoLanguage: Strictly typed ISO-4217 currency symbols (USD, EUR, GBP) and ISO-639-1 language codes.
  • Value Objects: Immutable TypeScript classes representing domain concepts like EmailAddress, UUID, and Money.

3. How It Works Under the Hood

Environment Validation & Value Object Resolution

sequenceDiagram
    autonumber
    participant App as Application Bootstrap
    participant Common as NodeYalcCommon
    participant Env as AppEnvResolver
    participant VO as Value Object Factory

    App->>Common: AppEnvResolver.resolve(process.env.NODE_ENV)
    Common->>Env: Normalize Environment String
    Env-->>Common: Returns AppEnvEnum.PRODUCTION
    App->>VO: Money.fromCents(1000, IsoCurrency.EUR)
    VO->>VO: Validate Non-Negative & ISO Code
    VO-->>App: Immutable Money Instance { amount: 10.00, currency: 'EUR' }

4. Why It Was Designed This Way

| Metric | Loose String Literals | @node-yalc/common Primitives | | :--- | :--- | :--- | | Typo Risk | High ("produciton", "x-correlation-ID"). | Zero. Enforced at compile time via TypeScript Enums. | | Refactoring | Manual search-and-replace across 50+ repositories. | IDE symbol rename propagates instantly across monorepo. | | Memory Footprint| Garbage collection thrashing on string re-allocations. | Frozen, immutably cached singleton constants. |


5. Practical Usage Guide & Extended Code Examples

5.1 Environment Check & Header Binding

import { AppEnvEnum, HttpHeaders, isProduction } from '@node-yalc/common';

export function setupSecurityHeaders(env: string, headers: Record<string, string>) {
  if (isProduction(env)) {
    headers[HttpHeaders.STRICT_TRANSPORT_SECURITY] = 'max-age=31536000; includeSubDomains';
  }

  headers[HttpHeaders.X_CORRELATION_ID] = 'corr_' + Date.now();
}

5.2 Type-Safe Money Value Object

import { Money, IsoCurrency } from '@node-yalc/common';

const price = Money.fromDecimal(49.99, IsoCurrency.USD);
const tax = price.multiply(0.20); // 20% VAT
const total = price.add(tax);

console.log(total.format()); // "$59.99"
console.log(total.toCents()); // 5999

6. Anti-Patterns: How NOT to Use It

[!CAUTION] Anti-Pattern 1: Hardcoding Environment Strings Never compare process.env.NODE_ENV === 'prod'. Always use AppEnvResolver.isProduction() to handle alias variants (prod, production).


7. Pro-Tips & Best Practices

[!TIP] Pro-Tip 1: Centralized Constant Export Import headers directly from HttpHeaders constant maps to maintain parity across frontend web clients, Node.js API gateways, and serverless functions.


🔗 Cross-References

To see how this module integrates with the rest of the Ferrox architecture, refer to the following documentation:


📚 Ecosystem Documentation

This module is a core component of the Ferrox enterprise microservice architecture.

👉 Read the Full Documentation on Ferrox-Rust.dev