Registry / database / nodejs-express-utils

nodejs-express-utils

JSON →
library1.1.36jsnpmunverified

Nodejs-Express-Utils is a utility package for Node.js and Express applications, providing middleware, a MySQL ORM with built-in AES encryption, and various helpers. Version 1.1.36 is the latest stable release, with infrequent updates. The package integrates AES encryption directly into the ORM using MySQL's AES_ENCRYPT/AES_DECRYPT functions, simplifying encrypted field storage. It also offers common middleware like rate limiting, validation via JOI, and a query builder similar to an ORM. Compared to other ORMs like Sequelize or TypeORM, this library is lightweight and focused on encryption out-of-the-box, but lacks extensive community support and comprehensive documentation. It supports TypeScript via included type definitions.

npm install nodejs-express-utils
INSTALL
IMPORT
SIG · NODEJS-EXPRESS-UTI
N
nodejs-express-utils
databasejavascriptv1.1.36
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.

mysqlORM
import { mysqlORM } from 'nodejs-express-utils'
const mysqlORM = require('nodejs-express-utils').mysqlORM
ESM imports are supported. CommonJS require is also valid but less common.
rateLimiter
import { rateLimiter } from 'nodejs-express-utils'
Named export for middleware.
validate
import { validate } from 'nodejs-express-utils'
import Validate from 'nodejs-express-utils'
validate is a named export, not default.

Demonstrates importing and using middleware (rate limiter, validation) and MySQL ORM with query method.

import express from 'express'; import { mysqlORM, rateLimiter, validate } from 'nodejs-express-utils'; const app = express(); // Rate limiter middleware app.use(rateLimiter({ windowMs: 15 * 60 * 1000, max: 100 })); // Validation middleware app.post('/user', validate({ name: 'string', age: 'number' }), (req, res) => { res.send('Validated'); }); // MySQL ORM example async function runORM() { const db = new mysqlORM({ host: 'localhost', user: 'root', password: process.env.DB_PASS || '', database: 'test' }); const users = await db.query('SELECT * FROM users'); console.log(users); } app.listen(3000, () => console.log('Server running'));
Debug
Known issues
gotchaMySQL ORM uses AES encryption by default; you must set encryption key via environment variable or config.
fix
Set ENCRYPTION_KEY in environment or pass encryptionKey in options to mysqlORM constructor.
affects: >=1.0.0
gotchaThe validate middleware uses JOI internally; schema must match JOI syntax exactly.
fix
Use JOI schema format, e.g., Joi.string() instead of 'string' for better control.
affects: >=1.0.0
gotchaRate limiter stores data in memory by default; not suitable for multi-process or distributed deployments.
fix
Use an external store like Redis with the store option when scaling horizontally.
affects: >=1.0.0
breakingVersion 1.1.0 changed mysqlORM constructor options; old 'connection' field is now 'host' + 'port'.
fix
Update constructor to use { host, user, password, database } object instead of { connection: { host, user, password, database } }.
affects: >=1.1.0
Errors
Common errors & fixes
TypeError: mysqlORM is not a constructor
Importing mysqlORM as a default export instead of named export.
fix
Use import { mysqlORM } from 'nodejs-express-utils' instead of import mysqlORM from 'nodejs-express-utils'.
Error: ENCRYPTION_KEY is required
Missing AES encryption key in environment or config.
fix
Set process.env.ENCRYPTION_KEY to a valid key string before initializing ORM.
ValidationError: "name" must be a valid Joi schema
Passing plain strings to validate() instead of JOI schema objects.
fix
Provide schema as Joi.object({ name: Joi.string() }) instead of { name: 'string' }.
Upgrade
Version history
1.1.36latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
nodejs-express-utils — npm install nodejs-express-utils · libregistry