Registry / devops / rest-docs

rest-docs

JSON →
library1.1.1jsnpmunverified

rest-docs (v1.1.1) is a RESTful HTTP client library that auto-generates API documentation and provides a monitoring dashboard. It bundles a Node.js HTTP server with automatic CRUD route generation for databases (PostgreSQL, MySQL, MariaDB, MSSQL, SQLite3) via Knex. Unlike generic API builders, it exposes live docs and monitoring endpoints out of the box. The last release appears to be 1.1.1 with no recent updates; it uses CommonJS and requires manual driver installation.

npm install rest-docs
INSTALL
IMPORT
SIG · REST-DOCS
R
rest-docs
devopsjavascriptv1.1.1
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.

rest-docs
const rest_docs = require('rest-docs')
import rest_docs from 'rest-docs'
The package uses CommonJS only; ESM imports will fail.
rest_docs
const rest_docs = require('rest-docs'); var rest = new rest_docs();
var rest = new rest_docs.rest()
The constructor is the default export; invoking .rest() is not needed.
startDBServer
rest.startDBServer('mysql', {...})
rest.startDBServer({...})
First argument is the database type (string), second is the config object.

Creates a RESTful API server with automatic CRUD routes, live docs, and monitoring for a 'doctors' table in MySQL.

const rest_docs = require('rest-docs'); var rest = new rest_docs(); rest.startServer({ ip: '127.0.0.1', port: '8080', compression: 'gzip' }); rest.startDBServer('mysql', { host: 'localhost', port: 3306, user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'medic', timezone: '+00:00' }); const api_config = { base: '/api', pages: { docs: true, monitor: true }, routes: { tb: [ { table: 'doctors', event: 'DOCTOR', methods: ['GET', 'POST', 'PUT', 'DELETE'], columns: [ {name: 'id', primary: true}, {name: 'name'}, {name: 'specialty'} ] } ] } }; rest.buildRoutes(api_config);
Debug
Known issues
gotchaPackage is CommonJS only. Importing via ES6 `import` will fail.
fix
Use require('rest-docs') instead of import.
affects: >=1.0.0
gotchaDatabase drivers are not included; must be installed separately.
fix
Install one of: pg, mysql, mssql, sqlite3.
affects: >=1.0.0
gotchaThe first argument to startDBServer() is the database type (string), not the config object.
fix
Call rest.startDBServer('mysql', { host: ... }) instead of rest.startDBServer({ host: ... }).
affects: >=1.0.0
gotchaColumns in routes config have no 'type' field; validation may fail for non-string columns.
fix
Ensure all column names exist in the database table.
affects: >=1.0.0
gotchaThe 'compression' option must be a string like 'gzip' or 'deflate'; boolean or other types may be ignored.
fix
Set compression to a valid string or omit it.
affects: >=1.0.0
gotchaTable names are case-sensitive; use the exact case as in the database.
fix
Use the correct table name casing.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'pg'
PostgreSQL driver not installed
fix
npm install pg --save
rest_docs is not a constructor
Using ES6 import instead of require
fix
Replace import with const rest_docs = require('rest-docs')
Cannot read property 'host' of undefined
startDBServer called without first argument (string)
fix
Call rest.startDBServer('mysql', { host: 'localhost', ... })
TypeError: Cannot read properties of undefined (reading 'forEach')
Missing routes.tb array in config
fix
Add routes: { tb: [] } to api_config
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
knexrequiredDatabase query builder
pgoptionalPostgreSQL driver
mysqloptionalMySQL/MariaDB driver
mssqloptionalMSSQL driver
sqlite3optionalSQLite driver
dotenvoptionalFor .env file loading
Agent activity
4 hits · last 30 days
node
4
Resources