Registry / database / stein-orm-rest

stein-orm-rest

JSON →
library11.7.3jsnpmunverified

Express.js REST controller for stein-orm, providing automatic CRUD routing with authorization hooks, query timing, and database abstraction. Current version 11.7.3. Part of the frameworkstein ecosystem, it requires stein-orm >=8 as a peer dependency. Released via npm, with a stable API focused on Express integration. Differentiators include a built-in timing system for monitoring slow queries and flexible custom authorization middleware per route.

npm install stein-orm-rest
INSTALL
IMPORT
SIG · STEIN-ORM-REST
S
stein-orm-rest
databasejavascriptv11.7.3
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.

RestController
import RestController from 'stein-orm-rest'
const RestController = require('stein-orm-rest').default
Default ESM export; CommonJS require with .default may fail if module not transpiled
RestController
const RestController = require('stein-orm-rest')
const { RestController } = require('stein-orm-rest')
CJS users should require the whole module, not destructure a named export
RestController type
import type { RestControllerType } from 'stein-orm-rest'
import { RestController } from 'stein-orm-rest' for types
TypeScript type imports are separate; RestController is a class, not a type

Creates an Express REST controller for the Task model with timing enabled and a slow-query warning callback.

import RestController from 'stein-orm-rest'; import { app } from './app'; // your Express app import Task from './models/Task'; // your stein-orm model const controller = new RestController(app, { modelType: Task, route: '/tasks', enableTiming: true, timingCallback: (timingData, req) => { if (timingData.duration > 500) { console.warn(`Slow query: ${timingData.duration}ms`); } } })
Debug
Known issues
breakingRestController constructor now requires 'route' option instead of 'path' since v10.0.0.
fix
Replace 'path' with 'route' in the options object.
affects: >=10.0.0
deprecatedUsing 'auth' as a single middleware function is deprecated; use an array instead.
fix
Wrap your auth function in an array: auth: [customAuth]
affects: >=9.0.0
gotchaThe 'enableTiming' option does not work unless 'modelType' has a 'fetchJSON' method.
fix
Ensure your model implements fetchJSON or use standard query methods instead.
affects: >=11.0.0
gotchaCommonJS require returns an object with a default property; destructuring may fail.
fix
Use const RestController = require('stein-orm-rest').default or import syntax.
affects: >=11.0.0
Errors
Common errors & fixes
TypeError: RestController is not a constructor
CommonJS require without .default when module uses ESM exports
fix
Use `const RestController = require('stein-orm-rest').default`
Cannot find module 'stein-orm'
Missing peer dependency stein-orm
fix
Run `npm install stein-orm@>=8`
TypeError: timingCallback is not a function
timingCallback provided but enableTiming not set to true
fix
Set `enableTiming: true` in the options
TypeError: Cannot read property 'route' of undefined
Route option missing in constructor options
fix
Provide `route` (string) in the options object
Upgrade
Version history
11.7.3latest on npm
Audit
Dependencies
stein-ormrequiredPeer dependency required for model types and database operations
Agent activity
12 hits · last 30 days
node
10
Meta
1
OpenAI (training)
1
Resources