$ account plexinc
Papr is a lightweight TypeScript library that provides type-safe schemas and JSON Schema validation for MongoDB collections. It wraps the official MongoDB Node.js driver, offering a familiar API (find, insertOne, updateOne, etc.) while automatically generating JSON Schema validators that are applied to MongoDB collections via `collMod` or `createCollection`. The library supports a wide range of BSON types, timestamps, defaults (static, dynamic, async), hooks (before/after), and custom filter types for enhanced type safety in queries and updates. It is designed as a thin, performant alternative to Mongoose, offloading validation to the MongoDB server. The codebase is well-structured with modular source files, extensive unit and type tests, benchmarks comparing performance against raw MongoDB driver and Mongoose, and comprehensive documentation. It is actively maintained with CI/CD pipelines, automated releases, and dependency management via Renovate.