Registry / database / mysql-endpoint-express

mysql-endpoint-express

JSON →
library1.0.6jsnpmunverified

A simple Express.js middleware that automatically creates REST API endpoints (CRUD) for a MySQL database table based on environment variables. Version 1.0.6 introduced role-based statement support. This package is essentially a quick starter for scaffolding a MySQL-connected Express API with minimal configuration, but it lacks proper documentation, testing, and security considerations. It is not actively maintained and may not be suitable for production use.

npm install mysql-endpoint-express
INSTALL
IMPORT
SIG · MYSQL-ENDPOINT-EXP
M
mysql-endpoint-express
databasejavascriptv1.0.6
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
require('mysql-endpoint-express')
import 'mysql-endpoint-express'
The package is CommonJS only and requires require(). ESM import will fail.
express
const express = require('express')
import express from 'express'
Express is a dependency but must be required separately for any custom use, though the package configures it internally.
mysql
const mysql = require('mysql')
import mysql from 'mysql'
MySQL driver is used internally, not directly exposed to user code.
dotenv
require('dotenv').config()
import dotenv from 'dotenv'
dotenv is used to load .env; must be required before the package.

Minimal setup: configure environment variables and require the package to automatically run an Express server with CRUD endpoints for a MySQL table.

// .env file DB_HOST=localhost DB_PORT=3306 DB_USER=root DB_PASSWORD=secret DB_DATABASE=mydb PREFIX_ROLE=admin ALLOWED_ORIGIN=* ALLOWED_METHODS=GET,POST,PUT,DELETE ALLOWED_HEADERS=Content-Type,Authorization // index.js require('dotenv').config(); require('mysql-endpoint-express'); // Server starts automatically on port 3000 with endpoints: // GET /api - list all records // GET /api/:id - get one record // POST /api - create record // PUT /api/:id - update record // DELETE /api/:id - delete record console.log('Server running on http://localhost:3000');
Debug
Known issues
breakingPackage auto-starts the Express server without giving user control over port or server options. Hardcoded port 3000.
fix
Set PORT=3000 in .env or modify package source. Alternatively, do not use this package if you need full server control.
affects: >=1.0.0
gotchaRequires a single table named after the database? Actually, table name is not configurable; it assumes a table named 'items' or similar? README and docs are missing.
fix
Review package source code to determine the expected table name, or set environment variable TABLE_NAME if supported.
affects: >=1.0.0
breakingNo input validation or SQL injection protection. The package directly uses user-supplied values in SQL queries.
fix
Add a separate validation layer or use parameterized queries inside the package. Not recommended for production without hardening.
affects: >=1.0.0
deprecatedUses the unmaintained 'mysql' npm package instead of the recommended 'mysql2'.
fix
Upgrade to mysql2 for better security and performance. But this package may not support it.
affects: >=1.0.0
gotchaNo error handling for database connection failures; server may crash silently.
fix
Wrap the require in a try-catch or implement custom error handling.
affects: >=1.0.0
Errors
Common errors & fixes
Error: listen EADDRINUSE :::3000
Port 3000 is already in use by another process (e.g., another instance of the app).
fix
Kill the process using port 3000 or change the PORT environment variable (though documentation says port is hardcoded).
Error: Cannot find module 'mysql'
Required dependency 'mysql' is not installed.
fix
Run 'npm install mysql' in your project directory.
TypeError: require(...) is not a function
Misunderstanding import; the package is not a function, it needs no assignment.
fix
Use just 'require('mysql-endpoint-express');' without assignment.
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server is not running or host/port incorrect.
fix
Ensure MySQL is running and DB_HOST, DB_PORT in .env are correct.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
expressrequiredRequired to create the Express application and define routes.
mysqlrequiredMySQL driver for connecting to the database.
dotenvrequiredUsed to load environment variables from .env file.
corsrequiredMiddleware for enabling CORS as configured in .env.
Agent activity
11 hits · last 30 days
node
10
Resources
mysql-endpoint-express — npm install mysql-endpoint-express · libregistry