Node.js/TypeScript implementation of the Jodit File Browser and Uploader connector.
Links:
- Jodit Editor - The WYSIWYG HTML editor
- Complete Documentation - Full documentation and API reference
- PHP Connector - Original PHP implementation
- Node.js LTS (v18+)
- TypeScript with strict typing
- Express 5.x for REST API
- Zod for runtime validation
- @hapi/boom for error handling
- Winston for logging
- Jest + Supertest for testing
npm install jodit-nodejsimport { start } from 'jodit-nodejs';
// Start server with default config
const server = await start(8081);
console.log('Server running on http://localhost:8081');const { start } = require('jodit-nodejs');
async function main() {
const server = await start(8081);
console.log('Server running on http://localhost:8081');
}
main().catch(console.error);import { start } from 'jodit-nodejs';
await start({
port: 8081,
config: {
debug: false,
allowCrossOrigin: true,
sources: {
uploads: {
name: 'uploads',
title: 'User Uploads',
root: '/var/www/uploads',
// NGINX or CDN base URL for accessing files
baseurl: 'http://localhost:8080/uploads/'
}
}
}
});import { start, type AuthCallback } from 'jodit-nodejs';
const checkAuth: AuthCallback = async (req) => {
const token = req.headers.authorization;
if (!token) return 'guest';
const user = await validateToken(token);
return user.role; // 'admin', 'editor', 'guest', etc.
};
await start({
port: 8081,
config: {
defaultRole: 'guest',
accessControl: [
{ role: 'guest', FILES: true, FILE_UPLOAD: false },
{ role: 'admin', FILES: true, FILE_UPLOAD: true }
]
},
checkAuthentication: checkAuth
});For enhanced security, you can restrict the API to only accept POST requests:
import { start } from 'jodit-nodejs';
await start({
port: 8081,
config: {
onlyPOST: true, // Block all GET requests
sources: {
uploads: {
name: 'uploads',
title: 'User Uploads',
root: '/var/www/uploads',
baseurl: 'http://localhost:8080/uploads/'
}
}
}
});When onlyPOST is enabled:
- All GET requests return 405 Method Not Allowed
- Provides protection against CSRF attacks
- Prevents parameter leakage in server logs
📖 Complete Documentation - Full documentation with guides and API reference
Quick Links:
- Getting Started - Installation and quick start
- Authentication - Cookie auth, JWT, express-session
- Access Control - ACL rules and permissions
- Configuration - All configuration options
- Express Integration - Integration patterns
- Storage Adapters - AWS S3, Azure, Google Cloud
- Docker Deployment - Docker guide
- API Reference - Complete API endpoints
OpenAPI Specification:
- ✅ Full file management - browse, upload, rename, move, delete
- ✅ Folder operations - create, rename, move, delete, tree view
- ✅ Image processing - resize, crop, thumbnail generation
- ✅ Document generation - PDF and DOCX from HTML
- ✅ Access control - role-based permissions, path restrictions
- ✅ Authentication - cookie, JWT, express-session support
- ✅ Security - POST-only mode, CSRF protection
- ✅ Express integration - standalone or integrate with existing apps
- ✅ Custom storage - local filesystem, S3, Azure, Google Cloud, etc.
- ✅ TypeScript - full type safety with strict typing
- ✅ Validation - Zod schemas for runtime validation
- ✅ Testing - comprehensive test suite with Jest + Supertest
- ✅ Docker - multi-stage build for production deployment
- ✅ actionFiles - get list of files
- ✅ actionFileUpload - upload files
- ✅ actionFileUploadRemote - upload file from remote URL
- ✅ actionFileRemove - remove files
- ✅ actionFileMove - move files
- ✅ actionFileRename - rename files
- ✅ actionFileDownload - download file
- ✅ actionGetLocalFileByUrl - resolve local file by URL
- ✅ actionFolderCreate - create folders
- ✅ actionFolderRemove - remove folders
- ✅ actionFolderMove - move folders
- ✅ actionFolderRename - rename folders
- ✅ actionFolders - get folder tree
- ✅ actionPermissions - get permissions
- ✅ actionImageResize - resize images
- ✅ actionImageCrop - crop images
- ✅ actionGenerateDocx - generate DOCX documents from HTML
- ✅ actionGeneratePdf - generate PDF documents from HTML
Check the examples/ directory for complete working examples:
examples/basic-js.js- Simple server setupexamples/with-auth-js.js- With authentication callbackexamples/with-cookie-auth.js- Cookie-based authenticationexamples/with-jwt-auth.js- JWT token authenticationexamples/with-express-session.js- Express-session integration
npm run dev # Development with hot reload
npm run build # Compile TypeScript
npm start # Run compiled application
npm test # Run tests
npm run lint # Check code quality# Build and run
docker build -t jodit-nodejs .
docker run --rm -p 8081:8081 jodit-nodejs
# With custom config
docker run --rm -p 8081:8081 \
-v /host/path/to/config.json:/usr/src/app/config.json \
-v /host/path/to/files:/usr/src/app/files \
jodit-nodejsMIT