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

@meridianjs/framework-utils

v2.6.0

Published

Utilities for building Meridian modules: DML, service factory, defineModule, defineLink

Readme

@meridianjs/framework-utils

Core building blocks for creating MeridianJS modules: the DML (Data Modelling Language), the MeridianService factory, Module(), defineLink(), and ORM utilities.

Installation

npm install @meridianjs/framework-utils

Overview

Every domain module in a MeridianJS application is built with the primitives this package exports. You define your data models with model, generate CRUD services with MeridianService, wire up a module with Module(), and declare cross-module relationships with defineLink().

API Reference

model — Data Modelling Language

Define a database entity without writing MikroORM decorators:

import { model } from "@meridianjs/framework-utils"

export const Project = model("project", {
  id:          model.id(),            // UUID primary key, auto-generated
  name:        model.text(),          // VARCHAR
  description: model.text(),
  color:       model.text(),
  is_active:   model.boolean(),
  sort_order:  model.number(),
  metadata:    model.json(),
  status:      model.enum(["active", "archived"]),
  created_at:  model.dateTime(),
  updated_at:  model.dateTime(),
})

model.id() automatically creates a uuid primary key with onCreate auto-generation. model.dateTime() fields named created_at / updated_at are set automatically on create and update.

MeridianService — Auto-generated CRUD

Pass a map of model names to model definitions and receive a class with full CRUD:

import { MeridianService } from "@meridianjs/framework-utils"
import type { MeridianContainer } from "@meridianjs/types"
import { Project } from "./models/project.js"
import { Label } from "./models/label.js"

export class ProjectModuleService extends MeridianService({ Project, Label }) {
  constructor(container: MeridianContainer) {
    super(container)
  }

  // Auto-generated for Project:
  //   listProjects(filters?, options?)
  //   listAndCountProjects(filters?, options?)
  //   retrieveProject(id)
  //   createProject(data)
  //   updateProject(id, data)
  //   deleteProject(id)
  //   softDeleteProject(id)

  // Auto-generated for Label:
  //   listLabels, retrieveLabel, createLabel, updateLabel, deleteLabel ...

  // Add custom methods here
}

Module() — Module Definition

Register a service + its models and loaders with the DI container:

import { Module } from "@meridianjs/framework-utils"

export default Module("projectModuleService", {
  service: ProjectModuleService,
  models: [Project, Label, Milestone],
  loaders: [defaultLoader],
  linkable: {
    project: { tableName: "project", primaryKey: "id" },
  },
})

The key (first argument) is the container registration token — this is the name used in container.resolve("projectModuleService") and in route handlers via req.scope.resolve("projectModuleService").

defineLink() — Cross-module Relationships

Declare a join table between two modules without coupling them via foreign keys:

import { defineLink } from "@meridianjs/framework-utils"
import ProjectModule from "@meridianjs/project"
import IssueModule from "@meridianjs/issue"

export default defineLink(
  { linkable: ProjectModule.linkable!.project },
  { linkable: IssueModule.linkable!.issue, isList: true, deleteCascades: true },
  { linkTableName: "project_issue_link", entryPoint: "projectIssueLink" }
)

ORM Utilities

Used inside module loaders to initialise per-module MikroORM instances:

import { dmlToEntitySchema, createModuleOrm, createRepository } from "@meridianjs/framework-utils"
import type { LoaderOptions } from "@meridianjs/types"
import { Project } from "../models/project.js"

const ProjectSchema = dmlToEntitySchema(Project)

export default async function defaultLoader({ container }: LoaderOptions) {
  const config = container.resolve("config") as any
  const orm = await createModuleOrm([ProjectSchema], config.projectConfig.databaseUrl)
  const em = orm.em.fork()
  container.register({
    projectRepository: createRepository(em, "project"),
    projectOrm: orm,
  })
}

Each module manages its own MikroORM instance and schema, keeping modules fully isolated from one another.

License

MIT