{"library":"node-uploadx","title":"node-uploadx Resumable Upload Middleware","description":"node-uploadx is a robust Node.js middleware designed for handling resumable file uploads, supporting protocols like Tus (implicitly, through its resumable features). It abstracts away the complexities of chunked uploads, error recovery, and storage management, making it suitable for applications requiring reliable file transfer. The library, currently at version 6.2.1, maintains a regular release cadence, primarily focusing on bug fixes, security enhancements, and minor feature additions as seen in recent patch versions. Key differentiators include its flexible storage options (local filesystem, S3, GCS), integrated metadata handling, built-in validation for file types and sizes, and extensibility for custom scenarios. It integrates seamlessly with popular Node.js frameworks like Express, providing a server-side backbone for client-side upload libraries such as Uppy or ngx-uploadx.","language":"javascript","status":"active","last_verified":"Thu Apr 23","install":{"commands":["npm install node-uploadx"],"cli":null},"imports":["import { Uploadx } from 'node-uploadx';","import { DiskStorage } from 'node-uploadx';","import { S3Store } from '@uploadx/s3';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import express from 'express';\nimport cors from 'cors';\nimport { Uploadx, DiskStorage } from 'node-uploadx';\nimport path from 'path';\n\nconst app = express();\nconst PORT = process.env.PORT || 3003;\nconst UPLOAD_DIR = path.resolve(process.cwd(), 'uploads');\n\n// Ensure the upload directory exists\nimport fs from 'fs';\nif (!fs.existsSync(UPLOAD_DIR)) {\n  fs.mkdirSync(UPLOAD_DIR, { recursive: true });\n}\n\napp.use(cors({ origin: '*', credentials: true })); // Configure CORS appropriately for production\n\napp.use(\n  '/uploads',\n  Uploadx.middleware({\n    storage: new DiskStorage({\n      directory: UPLOAD_DIR,\n      // Optional: Customize file naming\n      filename: (file) => {\n        const ext = path.extname(file.originalName);\n        const name = path.basename(file.originalName, ext);\n        return `${name}-${Date.now()}${ext}`;\n      },\n      // Optional: Set a maximum upload size\n      maxUploadSize: '10GB'\n    }),\n    // Optional: Callback after a file upload is complete\n    onComplete: (file) => {\n      console.log(`Upload complete for file: ${file.originalName} (${file.size} bytes) saved to ${file.filePath}`);\n    },\n    // Optional: Log level\n    logLevel: 'debug'\n  })\n);\n\napp.listen(PORT, () => {\n  console.log(`Upload server listening on port ${PORT}`);\n  console.log(`Uploads will be saved to: ${UPLOAD_DIR}`);\n});","lang":"typescript","description":"This quickstart sets up an Express server with node-uploadx to handle resumable file uploads to a local disk. It demonstrates basic configuration including CORS, a custom upload directory, filename generation, and a completion callback.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}