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

dreck

v2.0.2

Published

Helpers for express CRUD handlers

Readme

Dreck

Scaffolding to set up crud operations.

Install

npm install dreck

Configuration

{ 
	"dreck": {
		"publicFilesPrefix": "/dreck/files"
		, "alwaysProvideResources": false
	}
}

Integration

import dreckSetup from "dreck/initialize-webhandle-component.mjs"
let dreckManager = await dreckSetup(webhandle)

Making a type specific Hanlder

import {Dreck} from "dreck"
import InMemoryDataService from '@dankolz/in-memory-data-service'

let data = [ /* some data here */ ]
let dataService = new InMemoryDataService({ })
dataService.collections.default = data

class PeopleDreck extends Dreck {
	constructor(options) {
		super()
		
		this.safeAssignOptions( 
			{
				locals: {
					pretemplate: 'app_pre',
					posttemplate: 'app_post'
				}
			}
		)
		this.safeAssignOptions(options)
	}
}

let router = webhandle.createRouter()
let dreck = new PeopleDreck()
dreck.addToRouter(router)
webhandle.routers.primary.use('/people', router)

Options

What's going on here is a set of url handlers and templates to do CRUD operations. This makes it easy to edit different types of data. It operates in two modes: a sortable set of tiles, a sorted table of items.

To operate as a set of tiles, you need to set the template for editing the fields and for showing the specific information on the tile. This is in addition to specifying a template to be rendered before and after the content, providing a "frame" for the crud screens.

To set up a tiles dreck:

dreck = new Dreck({
	locals: {
		pretemplate: 'start'
		, posttemplate: 'end'
		, sortableTileContentTemplate: 'people/people-tile'
		, fieldsTemplate: 'people/people-fields'
	}
	, dataService: dataService
})

To set up a table style dreck, you need to specify a template for the table headers and the data TDs for each data row.

dreck = new Dreck({
	locals: {
		pretemplate: 'start'
		, posttemplate: 'end'
		, fieldHeaderCellsTemplate: 'people/people-list-header'
		, fieldDataCellsTemplate: 'people/people-list-row'
		, fieldsTemplate: 'people/people-fields'
	}
	, dataService: dataService
	, useSortOrder: false
})

dataService is an instance of @dankolz/abstract-data-service. The in memory service is useful for testing and building more complex services, but probably you'll want a mongodb collection to back it. This will be something like:

import MongoDataService from "@dankolz/mongodb-data-service";
import EventEmitter from "node:events";

let mongoDb = webhandle.primaryDatabase || webhandle.dbs['mydatabase'] || (/*something*/)
let collection = mongoDb.db.collection('collectionname')

let events = new EventEmitter()

let dataService = new MongoDataService({
	collections: {
		default: collection
	}
	, notification: events
})

Dreck injects request parameters into the focus object (the object being created or edited). This is done by the functions in dreck.injectors, each of which has the signature function(req, focus, next). By default, dreck will inject the properties from req.body (not including, id or _id) into the focus object.

Dreck also sets up data before the create/editor form is displayed. You can add code to run before the form is drawn by adding a function to dreck.formInformation with the signature async function(focus, req, res).