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

@mostajs/octoswitcher

v2.1.45

Published

Data access switcher — ORM direct or NET transport, one interface, zero config in modules

Downloads

918

Readme

@mostajs/octoswitcher

Data access switcher — ORM direct or NET transport, one interface, zero config in modules.

Principe

MOSTA_DATA=orm → @mostajs/orm → SQL direct (SQLite, PostgreSQL, Oracle, MSSQL, etc.)
MOSTA_DATA=net → @mostajs/net → Transport distant (REST, GraphQL, gRPC, WS, MCP)

Les modules @mostajs (auth, rbac, audit, settings, ticketing, secu) appellent getDialect() depuis octoswitcher — ils ne savent pas si les données viennent d'une base locale ou d'un serveur distant.

Installation

npm install @mostajs/octoswitcher

Usage dans un module

import { getDialect } from '@mostajs/octoswitcher'
import { UserRepository } from './repositories/user.repository.js'

const dialect = await getDialect()
const repo = new UserRepository(dialect)
const users = await repo.findAll()

Configuration (dans l'app, pas dans le module)

Mode ORM (accès direct base de données)

MOSTA_DATA=orm
DB_DIALECT=sqlite
SGBD_URI=./data/app.db

Mode NET (accès distant via transport)

MOSTA_DATA=net
MOSTA_NET_URL=https://mcp.amia.fr/astro_08/
MOSTA_NET_TRANSPORT=rest

API

getDialect(): Promise<IDataDialect>

Retourne le dialect singleton — ORM ou NET selon MOSTA_DATA.

getDataMode(): DataMode

Retourne 'orm' ou 'net'.

isNetMode(): boolean

Raccourci pour getDataMode() === 'net'.

isOrmMode(): boolean

Raccourci pour getDataMode() === 'orm'.

setDialect(dialect): void

Injecte un dialect externe (pour les tests).

resetDialect(): void

Réinitialise le singleton (pour les tests).

Architecture

App (.env.local)
 ├── MOSTA_DATA=net + MOSTA_NET_URL=...
 │
 ├── @mostajs/auth     → @mostajs/rbac → octoswitcher → getDialect()
 ├── @mostajs/rbac     → octoswitcher → getDialect()
 ├── @mostajs/audit    → octoswitcher → getDialect()
 ├── @mostajs/settings → octoswitcher → getDialect()
 ├── @mostajs/ticketing → octoswitcher → getDialect()
 └── @mostajs/secu     → octoswitcher → getDialect()
                              │
                    ┌─────────┴─────────┐
                    │                   │
              MOSTA_DATA=orm      MOSTA_DATA=net
              @mostajs/orm        @mostajs/net
              SQL direct          REST/GraphQL/gRPC

Modules migrés

| Module | Avant | Après | |--------|-------|-------| | rbac | 212 lignes (data-mode.ts + NET factories) | 106 lignes | | audit | 130 lignes (data-mode.ts + NET factories) | 41 lignes | | settings | 119 lignes (data-mode.ts + NET factories) | 41 lignes | | ticketing | hardcodé ORM | 1 import changé | | secu | hardcodé ORM | 1 import changé |

Licence

AGPL-3.0-or-later — Dr Hamid MADANI [email protected]