Registry / database / datahub-restful-core

datahub-restful-core

JSON →
library2.1.2jsnpmunverified

Export MySQL databases as RESTful APIs on Koa v1. Stable version 2.1.2. This package is specifically designed for Koa v1 (not v2) and provides automatic CRUD endpoints for MySQL tables with support for pagination, filtering, ordering, complex queries, and custom SQL. It is not actively maintained and relies on outdated dependencies. Key differentiators include built-in hooks, XLS export/import, and VM execution.

npm install datahub-restful-core
INSTALL
IMPORT
SIG · DATAHUB-RESTFUL-CO
D
datahub-restful-core
databasejavascriptv2.1.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.

DatahubRestfulCore
const { DatahubRestfulCore } = require('datahub-restful-core');
import { DatahubRestfulCore } from 'datahub-restful-core';
This package is CommonJS-only and does not support ESM imports.
DatahubRestfulCore
const core = new DatahubRestfulCore({...});
const core = new datahubRestfulCore.DatahubRestfulCore({...});
The constructor is exported directly as DatahubRestfulCore, not under a default export.
mount
app = core.mount(koa());
app = core.mount(require('koa')());
The mount method requires a Koa v1 instance (not v2). Use `koa()` directly.

Initializes the RESTful core, mounts it on a Koa v1 app, and starts the server to expose MySQL tables as API endpoints.

const koa = require('koa'); const { DatahubRestfulCore } = require('datahub-restful-core'); const port = process.env.PORT || 3003; const host = process.env.IP || '127.0.0.1'; const core = new DatahubRestfulCore({ port, host, name: 'demo', endpoint: '/', options: { client: 'mysql', connection: { host: '127.0.0.1', user: 'root', password: '', database: 'datahub', supportBigNumbers: true, bigNumberStrings: true, multipleStatements: true }, acquireConnectionTimeout: 60000, pool: { min: 0, max: 2 } } }); const app = core.mount(koa()); app.listen(port, host, () => { console.log('Datahub started http://%s:%s', host, port); }); // Test: curl http://127.0.0.1:3003/demo/
Debug
Known issues
deprecatedPackage requires Koa v1 which is deprecated and no longer maintained.
fix
Migrate to Koa v2 or use an alternative RESTful API library like feathers.js or loopback.
affects: >=0.0.0
gotchaThe package uses CommonJS and does not support ES modules.
fix
Use require() instead of import. If using ES modules, use dynamic import() or convert to CommonJS.
affects: >=0.0.0
gotchaThe mount() method expects a Koa v1 application instance. Passing Koa v2 will fail.
fix
Ensure you use koa@1.x, not koa@2+.
affects: >=0.0.0
gotchaThe password is required but defaults to empty string; if MySQL requires authentication, the connection will fail.
fix
Always set a password in the connection options, even if empty, or use environment variables.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: app.listen is not a function
mount() returns an object that is not a proper Koa app if called incorrectly.
fix
Ensure you pass the result of koa() (v1) to mount(), e.g., core.mount(koa()).
Error: Cannot find module 'koa'
koa is not installed or installed version is incompatible.
fix
Install koa version 1.x: npm install koa@1
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
MySQL credentials are incorrect or missing password.
fix
Check the connection object: provide correct host, user, password, and database.
Upgrade
Version history
2.1.2latest on npm
Audit
Dependencies
koaoptionalRequires Koa v1 (not v2 or higher) as a peer dependency for middleware mounting
knexrequiredUsed internally for MySQL connection and query building
Agent activity
6 hits · last 30 days
node
6
Resources
datahub-restful-core — npm install datahub-restful-core · libregistry