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

@soujvnunes/lib

v0.1.5

Published

Framework-agnostic stateful modules: serverless Mongoose client + Typegoose base models.

Readme

@soujvnunes/lib

Framework-agnostic stateful modules (the shared/lib counterpart to the pure @soujvnunes/util). Each subpath's dependencies are optional peers, so install only what the subpath you import needs.

./mongoose: serverless Mongoose client factory

createMongooseConnection({ mongoDbURI, ...connectOptions }) returns the access boundaries bound to that URI, cached on globalThis (survives lambda reuse and dev hot-reload) and attached to Vercel Fluid Compute. Any Mongoose ConnectOptions may be overridden; four are defaulted: bufferCommands: false, maxPoolSize: 10, serverSelectionTimeoutMS: 5000 and serverApi: { version: '1', strict: true, deprecationErrors: true }.

  • withDb(operation) connects, then runs the operation: the shape for a Server Component or any one-off async function.
  • withDbCallback(action) returns a function that connects on each call before running the action: the shape for a Server Action or a reusable async function.
pnpm add @soujvnunes/lib mongoose @vercel/functions
// shared/lib/mongodb.ts, call once, destructure the helpers
import { createMongooseConnection } from '@soujvnunes/lib/mongoose'

export const { connectDb, getDbClient, getDB, withDb, withDbCallback } = createMongooseConnection({
  mongoDbURI: process.env.MONGODB_URI,
  serverSelectionTimeoutMS: 2500, // optional override
})

// then, anywhere
export const getEntry = (key: string) => withDb(() => EntryModel.findOne({ key }).lean())

./typegoose: base model classes

BaseModel (subdocuments) and BaseTimestampedModel (main docs) both wire the mongoose-lean-virtuals plugin and virtuals: true, so .lean({ virtuals: true }) attaches the id string. Both type _id as a Mongoose ObjectId and id as a string. BaseTimestampedModel also extends Typegoose's TimeStamps and turns on timestamps, so createdAt and updatedAt are set and typed.

They stand in for Typegoose's Base interface, whose documented use merges an interface into the model class of the same name, a merge ESLint reports.

pnpm add @soujvnunes/lib @typegoose/typegoose mongoose mongoose-lean-virtuals reflect-metadata
import { BaseTimestampedModel } from '@soujvnunes/lib/typegoose'

export class Entry extends BaseTimestampedModel {
  public id!: string
  // @prop() fields...
}

Requires experimentalDecorators in the consumer's tsconfig.json, plus emitDecoratorMetadata if you want a bare @prop() to infer its type. Without the metadata, Typegoose rejects the field with Type is: "undefined" [E009], so give each prop an explicit type instead: @prop({ type: () => String }).