Registry / storage / arrest

arrest

JSON →
library15.0.2jsnpmunverified

A powerful OpenAPI v3.1 compliant REST framework for Node.js with comprehensive MongoDB support, JSON Schema validation, OAuth2 authentication, and CASL authorization. Current stable version 15.0.2 (released Jan 2025) aligns with MongoDB 7.x via bson 7.x. Key differentiators: automatic OpenAPI spec generation, built-in MongoDB CRUD operations, RQL querying, and JSON Patch support. Release cadence is major versions every 12–18 months. ESM-only with Node.js >=20 required; includes full TypeScript definitions. Integrates with Express.js and supports JSON-RPC endpoints.

npm install arrest
INSTALL
IMPORT
SIG · ARREST
A
arrest
storagejavascriptv15.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

API
import { API } from 'arrest'
const API = require('arrest').API
ESM-only since v15; no CommonJS support.
MongoResource
import { MongoResource } from 'arrest'
import { MongoResource } from 'arrest/lib/MongoResource'
Do not import from internal paths; public symbols are exported from the package root.
Resource
import { Resource } from 'arrest'
const Resource = require('arrest').Resource
Use named import; there is no default export for Resource.

Create a minimal CRUD API backed by MongoDB with automatic OpenAPI spec generation.

import { API, MongoResource } from 'arrest'; const api = new API({ title: 'My API', version: '1.0.0' }); api.addResource(new MongoResource(process.env.MONGO_URI ?? 'mongodb://localhost:27017/mydb', { name: 'User', collection: 'users' })); api.listen(3000); console.log('API running at http://localhost:3000'); console.log('OpenAPI spec at http://localhost:3000/openapi.json');
Debug
Known issues
breakingv15 dropped Node.js <20 support and switched to ESM-only (no CommonJS).
fix
Upgrade Node.js to >=20 and convert project to ESM (use import, not require).
affects: >=15.0.0
breakingMongoResource now requires MongoDB 7.x. Connection string must reference a MongoDB 7.x server.
fix
Upgrade MongoDB server to 7.x or stick with arrest v14.
affects: >=15.0.0
breakingbson major version bump to 7.x changed ObjectId behavior. `_id` is now returned as a 24-character hex string by default.
fix
Use `new bson.ObjectId(id)` to convert hex strings to ObjectIds if needed.
affects: >=15.0.0
gotchaOpenAPI spec endpoint is at /openapi.json by default; ensure no other middleware conflicts.
fix
Configure `specPath` option in API constructor to change the path.
affects: >=1.0.0
gotchaResource names must be singular; arrest automatically pluralizes for endpoints. Using a plural name may cause unexpected route generation.
fix
Use singular names (e.g., 'User' not 'Users').
affects: >=1.0.0
deprecated`api.addResource()` with a plain object (without `name` and `collection`) is deprecated. Always provide a `MongoResource` instance.
fix
Pass a `MongoResource` or custom `Resource` instance.
affects: >=15.0.0 <16.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/arrest/src/index.js from ... not supported.
arrest v15 is ESM-only; CommonJS require is not supported.
fix
Use `import` syntax or switch to dynamic import: `const arrest = await import('arrest')`.
MongoError: bad auth Authentication failed.
MongoDB connection string missing credentials or incorrect database permissions.
fix
Use `mongodb://user:password@host:port/db?authSource=admin` with correct credentials.
ValidationError: should have required property 'name'
Missing required field in request body as per JSON Schema.
fix
Check the schema defined for the resource; include all required fields in the request.
TypeError: api.addResource is not a function
Importing incorrectly (e.g., `import arrest from 'arrest'` instead of `import { API } from 'arrest'`).
fix
Use named imports: `import { API } from 'arrest'` and instantiate `new API()` before calling methods.
Upgrade
Version history
15.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
53 hits · last 30 days
node
46
OpenAI (training)
1
Resources
packagearrest
arrest — npm install arrest · libregistry