{"id":42008,"library":"stein-orm-rest","title":"Stein ORM REST Controller","description":"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.","status":"active","version":"11.7.3","language":"javascript","source_language":"en","source_url":"https://github.com/founderlab/frameworkstein#master","tags":["javascript"],"install":[{"cmd":"npm install stein-orm-rest","lang":"bash","label":"npm"},{"cmd":"yarn add stein-orm-rest","lang":"bash","label":"yarn"},{"cmd":"pnpm add stein-orm-rest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for model types and database operations","package":"stein-orm","optional":false}],"imports":[{"note":"Default ESM export; CommonJS require with .default may fail if module not transpiled","wrong":"const RestController = require('stein-orm-rest').default","symbol":"RestController","correct":"import RestController from 'stein-orm-rest'"},{"note":"CJS users should require the whole module, not destructure a named export","wrong":"const { RestController } = require('stein-orm-rest')","symbol":"RestController","correct":"const RestController = require('stein-orm-rest')"},{"note":"TypeScript type imports are separate; RestController is a class, not a type","wrong":"import { RestController } from 'stein-orm-rest' for types","symbol":"RestController type","correct":"import type { RestControllerType } from 'stein-orm-rest'"}],"quickstart":{"code":"import RestController from 'stein-orm-rest';\nimport { app } from './app'; // your Express app\nimport Task from './models/Task'; // your stein-orm model\n\nconst controller = new RestController(app, {\n  modelType: Task,\n  route: '/tasks',\n  enableTiming: true,\n  timingCallback: (timingData, req) => {\n    if (timingData.duration > 500) {\n      console.warn(`Slow query: ${timingData.duration}ms`);\n    }\n  }\n})","lang":"javascript","description":"Creates an Express REST controller for the Task model with timing enabled and a slow-query warning callback."},"warnings":[{"fix":"Replace 'path' with 'route' in the options object.","message":"RestController constructor now requires 'route' option instead of 'path' since v10.0.0.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Wrap your auth function in an array: auth: [customAuth]","message":"Using 'auth' as a single middleware function is deprecated; use an array instead.","severity":"deprecated","affected_versions":">=9.0.0"},{"fix":"Ensure your model implements fetchJSON or use standard query methods instead.","message":"The 'enableTiming' option does not work unless 'modelType' has a 'fetchJSON' method.","severity":"gotcha","affected_versions":">=11.0.0"},{"fix":"Use const RestController = require('stein-orm-rest').default or import syntax.","message":"CommonJS require returns an object with a default property; destructuring may fail.","severity":"gotcha","affected_versions":">=11.0.0"}],"env_vars":null,"search_vec":"'11.7.3':26 '8':37 'abstract':23 'api':48 'author':17,68 'automat':13 'built':57 'built-in':56 'control':4,7 'crud':14 'current':24 'custom':67 'databas':22 'depend':41 'differenti':53 'ecosystem':31 'express':51 'express.js':5 'flexibl':66 'focus':49 'frameworkstein':30 'hook':18 'includ':54 'integr':52 'javascript':72 'middlewar':69 'monitor':62 'npm':44 'orm':2,11,36 'part':27 'peer':40 'per':70 'provid':12 'queri':19,64 'releas':42 'requir':33 'rest':3,6 'rout':15,71 'slow':63 'stabl':47 'stein':1,10,35 'stein-orm':9,34 'system':60 'time':20,59 'version':25 'via':43","created_at":"2026-06-04T18:55:10.750432+00:00","updated_at":"2026-06-04T18:55:10.750432+00:00","problems":[{"fix":"Use `const RestController = require('stein-orm-rest').default`","cause":"CommonJS require without .default when module uses ESM exports","error":"TypeError: RestController is not a constructor"},{"fix":"Run `npm install stein-orm@>=8`","cause":"Missing peer dependency stein-orm","error":"Cannot find module 'stein-orm'"},{"fix":"Set `enableTiming: true` in the options","cause":"timingCallback provided but enableTiming not set to true","error":"TypeError: timingCallback is not a function"},{"fix":"Provide `route` (string) in the options object","cause":"Route option missing in constructor options","error":"TypeError: Cannot read property 'route' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/founderlab/frameworkstein/tree/master#readme","github":"https://github.com/founderlab/frameworkstein#master","docs":null,"changelog":null,"pypi":null,"npm":"stein-orm-rest","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}