New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

hexon

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexon

Framework-agnostic DDD-lite core for hexagonal architecture

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

hexon

Framework-agnostic DDD-lite core for hexagonal architecture

NPM JavaScript Style Guide Downloads

✨ Overview

  • hexon is a lightweight, framework-agnostic toolkit for building applications using Domain-Driven Design (DDD-lite) and Hexagonal / Clean Architecture principles.

  • It focuses on clear domain boundaries, not frameworks.

🎯 Features

  • ✅ Entities & Value Objects
  • ✅ Use Cases (Application layer)
  • ✅ Typed Dependency Injection
  • ✅ Domain-safe error handling
  • ✅ Framework-agnostic (Node, Browser, Worker)
  • ❌ No React
  • ❌ No UI
  • ❌ No magic

📦 Installation

npm install hexon
# or
yarn add hexon
# or
pnpm add hexon

🚀 Usage Example

1️⃣ Domain Entity
import { Entity, DomainError } from "hexon"

export class UserAccount extends Entity<string> {
  constructor(
    id: string,
    private active: boolean
  ) {
    super(id)
  }

  activate() {
    if (this.active) {
      throw new DomainError("Account is already active")
    }
    this.active = true
  }

  isActive() {
    return this.active
  }
}
2️⃣ Repository Interface (Domain Port)
export interface UserAccountRepository {
  get(id: string): Promise<UserAccount>
  save(account: UserAccount): Promise<void>
}
3️⃣ Use Case (Application Layer)
import { UseCase, Result, ok } from "hexon"

type Input = { userId: string }

export class ActivateAccount
  implements UseCase<Input, UserAccount>
{
  constructor(
    private readonly repo: UserAccountRepository
  ) {}

  async execute(
    input: Input
  ): Promise<Result<UserAccount>> {
    const account = await this.repo.get(input.userId)

    account.activate()
    await this.repo.save(account)

    return ok(account)
  }
}
4️⃣ Dependency Injection
import { createToken, container } from "hexon"

const USER_ACCOUNT_REPOSITORY =
  createToken<UserAccountRepository>(
    "UserAccountRepository"
  )

container.register(
  USER_ACCOUNT_REPOSITORY,
  () => new ApiUserAccountRepository()
)
5️⃣ Runtime Execution
const repo = container.resolve(USER_ACCOUNT_REPOSITORY)
const useCase = new ActivateAccount(repo)

const result = await useCase.execute({
  userId: "user-1"
})

if (result.ok) {
  console.log(
    "Account active:",
    result.data.isActive()
  )
}

🧠 Architecture Philosophy

Domain
 ├─ Entities
 ├─ Value Objects
 └─ Business Rules

Application
 ├─ Use Cases
 └─ Ports (Interfaces)

Infrastructure
 ├─ API / DB / Cache
 └─ Adapters (outside hexon)
  • hexon lives in the center.
  • Frameworks stay at the edges.

📄 License

MIT

Keywords

ddd

FAQs

Package last updated on 24 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts