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

supercrud

v0.0.3

Published

A small library to generate declerative route handlers for any types of models.

Readme

WIP: Supercrud

Build Status

WIP: A small, opinionated library to generate functional, testable, and readable CRUD handlers for your database models. Works with any ORM or even raw SQL code as you specify how to create, read, update and delete your models. Can be used with any web framework.

Context

Writing route handlers for web applications in Node.js

Problem

You find yourself writing almost identical CRUD handlers for all your database models. This includes input-checking, validation, how the model gets created/read/updated/deleted, and the formatted response to the user. The code imperative and may require some effort to understand for new developers.

Without Supercrud

// Route handler to create a new user in Express
app.post('/user', (req, res) => {
  if(req.body.username && req.body.password){
    new UserModel({username: req.body.username, password: req.body.password})
      .save()
      .then(savedUser => {
        res.send({message: 'User saved.', data: savedUser});
      });
  } 
  else {
    // Handle missing field(s)
  }
})

app.post('/article', addUsernameToRequest, (req, res) => {
  if(req.body.title && req.body.text){
    new ArticleModel({title: req.body.title, text: req.body.text, created_by: req.username })
      .save()
      .then(savedArticle => {
        res.send({message: 'Article saved.', data: savedArticle});
      });
  } 
  else {
    // Handle missing field(s)
  }
})

With Supercrud

// 1. Define your save function. (See other examples for update, deleted and get functions.)
// This is done only once and will work for all of your models assuming they have the same methods.
// You may export the CRUD object if you like to manage distinct models in seperate files.

import Supercrud from 'supercrud';

const CRUD = Supercrud({
  saveFunction: (generalModel, body) => new generalModel(body).save()
  // Other functions: updateFunction, getFunction, deleteFunction
});


// 2. Create your handlers. The returned handlers will call your saveFunction.

const userHandler = CRUD.create(UserModel, {
  requiredFields: ['username', 'password'],
  after: savedUser => ({ message: 'User saved.', data: savedUser})
})

const articleHandler = CRUD.create(ArticleModel, {
  requiredFields: ['title', 'text'],
  allowedFields: ['title', 'text'],
  before: (body, request) => Object.assign({}, body, { created_by: req.username }),
  after: savedUser => ({ message: 'User saved.', data: savedUser})
})

// 3. Hook it up to Express, Restify or whatever web framework you use.

app.post('/user', (req, res) => {
  userHandler(req.body).then(response => res.send(response))
})
app.post('/article', addUsernameToRequest, (req, res) => {
  articleHandler(req.body).then(response => res.send(response))
})

or with async await

app.post('/user', async (req, res) => res.send(await userHandler(req.body))
app.post('/article', addUsernameToRequest, async (req, res) => res.send(await articleHandler(req.body))

Benefits of Supercrud

Supecrud aims to make your code more readable and reduce boilerplate. In addition, since we are seperating the logic of the handlers into smaller functions (before, after) without side-effects, we can easily write good unit tests to verify the correctness of the code.