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

@keltoi/hydra-ts

v1.1.23

Published

Keltoi.Hydra.TS

Readme

Keltoi.Hydra.TS

│ A TypeScript repository skeleton that embraces the Repository Pattern inside a hexagonal (ports ↔ adapters) architecture.
│ Designed to be dropped into any project that wants a clean separation between domain logic, persistence, and infrastructure.


Why this structure?

┌──────────────────┬────────────────────────────────────────────────────────────┐ │ Benefit │ Why it matters │ ├──────────────────┼────────────────────────────────────────────────────────────┤ │ Domain‑centric │ The core never imports adapters; business rules stay │ │ │ isolated and fully testable. │ ├──────────────────┼────────────────────────────────────────────────────────────┤ │ Swap‑out │ Persist a type in‑memory, DB, or external API without │ │ adapters │ touching entities. │ ├──────────────────┼────────────────────────────────────────────────────────────┤ │ CQRS ready │ Separate command and query handlers, with well‑typed │ │ │ Result/Ok/Error types. │ ├──────────────────┼────────────────────────────────────────────────────────────┤ │ Audit & Identity │ Built‑in IEntity, ITraceable, IChangeable, and linking │ │ │ helpers give every record a stable key and change history. │ ├──────────────────┼────────────────────────────────────────────────────────────┤ │ Consistent │ Every repo returns a Result or IOk, so callers can │ │ outcomes │ handle success/failure uniformly. │ └──────────────────┴────────────────────────────────────────────────────────────┘


Directory layout

src/ ├── core/ # Domain primitives (entities, result monad, factory helpers) ├── context/ # Ports for API, DB, etc. ├── handler/ # CQRS orchestrators (use‑case, query, command) ├── repository/ # Repository interfaces & concrete adapters └── index.ts # Public façade

context

  • api/ – API‑side ports (IApiRepository, IReadRepository, …)
  • db/ – DB‑side ports (IDbContext, IDbRepository, paging/search interfaces)
  • chain.ts – pipeline adapter

handler

  • useCase.ts – IUseCaseHandler<TParam,TResult>
  • query.ts – IQueryHandler<TQuery,TResult>
  • command.ts – ICommandHandler
  • node.ts – INode building blocks
  • chain.ts – chains nodes into pipelines

repository

  • api/interface/ – high‑level API contracts
  • db/interface/ – DB contracts (paging, searching, ordering)
  • db/ – concrete adapters (ThingRepository, SubstanceRepository, …)

Core domain primitives – Quick reference

┌──────────────────────────┬─────────────────────────────────────────────────────┐ │ Interface / Class │ Role in repository pattern │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IEntity │ Persistable domain object (primary key + │ │ │ serialisation) │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IBeing │ Entity with a textual description │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IThing │ Entity with a name │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ ISubstance │ Combines Being & Thing │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IModel<TKey,TEntity> │ DTO representation + validate() → Result │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ Result │ Operation outcome (HTTP‑style status, data, error) │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IOk │ Lightweight success wrapper │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IError │ Structured error payload │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ ITraceable │ Created timestamp │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IChangeable │ Updated timestamp + active flag │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ IKeyLinking<TKeyA,TKeyO> │ Composite key for relations │ ├──────────────────────────┼─────────────────────────────────────────────────────┤ │ ILinking<TAbs,TOri> │ Edge between two entities │ └──────────────────────────┴─────────────────────────────────────────────────────┘

These interfaces give every repository a predictable API:

// Example of a repository method create(entity: IEntity): Result<IEntity> { // persist -> return Result with status code, maybe entity ID }


Setup & Building

Install dependencies

npm install

Compile TS → JS

npm run build

Run tests

npm test

Compiled output lives in dist/.

Basic Usage

import { DbContext, ThingRepository } from './dist';

const ctx = new DbContext(/* options */); const repo = new ThingRepository(ctx);

// Create a new "Thing" const result = await repo.create({ name: 'Example' });

if (result.isError) { console.error('Failed', result.error); } else { console.log('Created Thing with ID', result.ok.data.id); }

│ Tip:
│ All repository operations return a Result<T> or IOk<T>, so you can check isError/isOk without try/catch.


Contributing

  1. Fork the repo.
  2. Create a feature branch.
  3. Run npm test – all tests should pass.
  4. Commit, push, and open a PR.

Adhere to existing style: no console logs in production code, use the core types, keep repositories thin and focused on persistence only.


License

MIT © Keltoi.io