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

@spinajs/orm-http

v2.0.531

Published

Orm extensions for HTTP module

Readme

@spinajs/orm-http

Glue between @spinajs/orm and @spinajs/http: route arguments that load or build models straight from a request, a declarative filtering layer, and DTO fields that resolve to database entities.

It does not generate controllers or routes. You write ordinary @spinajs/http controllers; this package removes the boilerplate inside them.

Install

npm install @spinajs/orm-http

Importing it is enough — its bootstrapper registers itself with DI and runs when the ORM resolves.

Usage

import { BaseController, BasePath, Get, Post, Ok } from '@spinajs/http';
import { Connection, Model, ModelBase, Primary } from '@spinajs/orm';
import { FromModel, AsModel, Filter, Filterable, IFilterRequest } from '@spinajs/orm-http';

@Connection('default')
@Model('articles')
export class Article extends ModelBase<Article> {
  @Primary()
  public Id: number;

  @Filterable(['eq', 'like'])
  public Title: string;
}

@BasePath('articles')
export class ArticleController extends BaseController {
  /** GET /articles/:article — loaded by primary key, 404 when missing. */
  @Get(':article')
  public one(@FromModel() article: Article) {
    return new Ok(article.dehydrate());
  }

  /** GET /articles?filter={"op":"and","filters":[{"Column":"Title","Operator":"like","Value":"x"}]} */
  @Get()
  public async list(@Filter(Article) filter: IFilterRequest) {
    const rows = await Article.select().filter(filter.filters, filter.op);
    return new Ok(rows.map((r) => r.dehydrate()));
  }

  /** POST /articles — hydrated from the body, not fetched or saved. */
  @Post()
  public async create(@AsModel() article: Article) {
    await article.insert();
    return new Ok(article.dehydrate());
  }
}

What it adds

| Feature | Entry point | | --- | --- | | Load a model from a route / query / body / header parameter | @FromModel() | | Build an unsaved model from the request body | @AsModel() | | Declarative, schema-validated filtering | @Filterable() + @Filter() | | DTO fields that resolve to entities | @Relation() | | Pagination and ordering DTOs | PaginationDTO, OrderDTO | | 404 for OrmNotFoundException | OrmNotFound |

It also installs filter(), filterColumns() and filterSchema() onto every model class.

Documentation

Full documentation lives in docs/.

| | Page | | --- | --- | | 01 | Overview | | 02 | Route arguments | | 03 | Filtering | | 04 | DTO relations | | 05 | Pagination and ordering | | 06 | Repository middleware |

Known issues

  • RepositoryMiddleware is defined in src/middleware.ts but re-exported from neither src/index.ts nor the exports map, so it is currently unreachable. Use QueryMiddleware from the core instead — see docs/06.
  • npm test fails during bootstrap with No __file_provider_instance__ registered: the test harness does not register @spinajs/fs. That is a test-configuration gap, not a defect in the package.

Development

npm run build
npm run docs:check   # from the repo root