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:
- π OpenAPI YAML
- π OpenAPI JSON
- β 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