Nomine: Express Middleware for File Renaming
raw JSON →Nomine is an Express.js middleware package that facilitates renaming files and folders through HTTP PUT requests. It provides a straightforward API to expose a file renaming endpoint within an Express application, which is typically used for administrative interfaces or content management systems that require remote file system manipulation. The current stable version is 4.0.0, which mandates Node.js version 10 or higher, continuing a pattern of dropping support for older Node.js versions in each major release. The package's release cadence is driven primarily by updates to its internal dependencies and adjustments to Node.js compatibility. Its main differentiator is its direct integration into the Express ecosystem, offering a pre-packaged solution for network-based file renaming operations, abstracting the underlying file system interactions by utilizing the `renamify` package for the core renaming logic.
Common errors
error EACCES: permission denied, rename '/bin' -> '/bin2' ↓
/bin on production servers. Use relative paths or explicitly designated user data directories. error Error: Router.use() requires a middleware function but got a undefined ↓
const nomine = require('nomine'); is at the top of your file and that app.use(nomine({ /* options */ })); is used, calling nomine() to get the middleware function. Warnings
breaking Nomine v4.0.0 dropped support for Node.js versions older than 10. Applications running on Node.js 8 or earlier will not function correctly. ↓
breaking Nomine v3.0.0 dropped support for Node.js versions older than 8. ↓
breaking Nomine v2.0.0 dropped support for Node.js versions older than 4. ↓
gotcha Exposing file system operations via HTTP, especially rename, presents significant security risks. Without robust authentication and authorization mechanisms in place, an attacker could rename critical system files. ↓
Install
npm install nomine yarn add nomine pnpm add nomine Imports
- nomine wrong
import nomine from 'nomine';correctconst nomine = require('nomine'); - MiddlewareUsage wrong
app.use(nomine);correctapp.use(nomine({ prefix: '/rename' }));
Quickstart
const express = require('express');
const nomine = require('nomine');
const app = express();
// Use nomine middleware with a custom prefix
app.use(nomine({
prefix: '/files/rename' // default is '/rename'
}));
app.listen(3000, function () {
console.log('Nomine example app listening on port 3000!');
console.log('Send PUT requests to http://localhost:3000/files/rename');
console.log('Example curl: curl -X PUT -H "Content-Type: application/json" -d \'{"dir":"/tmp","from":["oldfile.txt"], "to": ["newfile.txt"]}\' http://localhost:3000/files/rename');
});