Registry / database / rest-mysql

rest-mysql

JSON →
library1.0.19jsnpmunverified

Rest-mysql is a minimal REST server that auto-generates CRUD endpoints from MySQL database schema. Current stable version 1.0.19, low release cadence. Differentiators: zero-config REST API from any MySQL database, TypeScript types included, simple router pattern. Limited flexibility compared to ORM-based solutions.

npm install rest-mysql
INSTALL
IMPORT
SIG · REST-MYSQL
R
rest-mysql
databasejavascriptv1.0.19
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.

default
import RestMysql from 'rest-mysql'
const RestMysql = require('rest-mysql')
ESM-only package, no CommonJS support
RestMysqlConfig
import type { RestMysqlConfig } from 'rest-mysql'
import { RestMysqlConfig } from 'rest-mysql'
Type import for TypeScript config type
RouteConfig
import type { RouteConfig } from 'rest-mysql'
Type import for route config interface

Initialize a REST server from MySQL database config, listening on port 3000.

import RestMysql from 'rest-mysql'; const config = { host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' }; const app = new RestMysql(config); app.listen(3000, () => { console.log('REST server running on port 3000'); });
Debug
Known issues
gotchaThe package requires a running MySQL instance; no automatic database creation.
fix
Ensure MySQL server is accessible with provided credentials.
affects: *
gotchaTable names are directly exposed as endpoints; ensure no sensitive tables are exposed.
fix
Use a separate database user with limited table access.
affects: *
breakingBreaking change in v1.0.0: Constructor now expects a config object instead of connection string.
fix
Upgrade to config object format {'host': '...', 'user': '...', ...}
affects: <1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rest-mysql'
Package not installed or ESM module not properly resolved
fix
npm install rest-mysql and ensure project uses ES modules (type: module in package.json) or import with .js extension.
TypeError: RestMysql is not a constructor
Incorrect import style (CommonJS require used instead of ESM import)
fix
Use 'import RestMysql from 'rest-mysql'' instead of 'require()'.
Error: Cannot connect to MySQL server
MySQL host/port/credentials incorrect or MySQL not running
fix
Verify MYSQL_HOST, MYSQL_PORT, user, password, and database name.
Upgrade
Version history
1.0.19latest on npm
Audit
Dependencies
mysqlrequiredMySQL database driver for Node.js
Agent activity
7 hits · last 30 days
node
6
Meta
1
Resources
rest-mysql — npm install rest-mysql · libregistry