{"id":17986,"library":"tus","title":"Tus Resumable Upload Middleware for Node.js","description":"This package, `tus` (version 0.1.7), provides a Node.js middleware for Express and Connect applications, implementing the tus resumable upload protocol. Originally designed for older versions of Express and Connect, it allows clients to pause and resume file uploads, making it suitable for large files or unreliable network conditions. The package's last update was nine years ago, making it effectively abandoned and incompatible with modern Node.js ecosystems, recent Express/Connect versions, and current JavaScript module standards (ESM). It lacks active maintenance, security patches, and contemporary features found in actively developed alternatives like `tus-node-server`. Its release cadence was sporadic, reflecting a period of early development for the tus protocol itself.","status":"abandoned","version":"0.1.7","language":"javascript","source_language":"en","source_url":"git://github.com/niklasvh/tus","tags":["javascript","tus","upload","resumable","connect","express"],"install":[{"cmd":"npm install tus","lang":"bash","label":"npm"},{"cmd":"yarn add tus","lang":"bash","label":"yarn"},{"cmd":"pnpm add tus","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for integrating the middleware into an Express application. The package was designed for older Express versions.","package":"express","optional":true},{"reason":"Runtime dependency for integrating the middleware into a Connect application. The package was designed for older Connect versions.","package":"connect","optional":true}],"imports":[{"note":"This package is CommonJS-only and does not support ES Modules. Attempting to use `import` will result in a runtime error.","wrong":"import { createServer } from 'tus';","symbol":"createServer","correct":"const tus = require('tus');\nconst uploadMiddleware = tus.createServer({ ... });"},{"note":"As a CommonJS package, it exports a single object containing the `createServer` function. ES Module `import * as` syntax is not directly compatible.","wrong":"import * as tus from 'tus';","symbol":"* as tus","correct":"const tus = require('tus');"}],"quickstart":{"code":"const express = require('express');\nconst tus = require('tus');\nconst path = require('path');\nconst fs = require('fs');\n\nconst app = express();\nconst port = 3000;\n\n// Ensure the upload directory exists\nconst uploadDir = path.join(__dirname, 'uploads');\nif (!fs.existsSync(uploadDir)) {\n    fs.mkdirSync(uploadDir);\n}\n\napp.use('/files', tus.createServer({\n    directory: uploadDir,\n    maxFileSize: 1024 * 1024 * 5, // 5 MB limit\n    complete: function(req, res, next) {\n        console.log('File upload complete with metadata:', req.upload);\n        // In modern Express, use res.status().send() or res.sendStatus()\n        // For older Connect/Express, res.end() was common for simple responses.\n        res.status(200).send('Upload successful');\n        // If not calling next(), ensure the response is manually handled.\n    }\n}));\n\napp.listen(port, () => {\n    console.log(`Tus server listening on port ${port}`);\n    console.log(`Upload directory: ${uploadDir}`);\n});\n\n// Example: Basic route to serve the client-side uploader (not included in this snippet)\napp.get('/', (req, res) => {\n    res.send('Tus upload server running. Use a tus client to upload to /files.');\n});","lang":"javascript","description":"Demonstrates how to set up the `tus` middleware with Express, configure the upload directory, set a maximum file size, and handle the `complete` callback for finished uploads."},"warnings":[{"fix":"Migrate to an actively maintained tus server implementation, such as `tus-node-server`, which supports modern Node.js and Express versions. This will require a complete re-implementation of the server-side upload logic.","message":"This package is heavily outdated (last updated 9 years ago) and is incompatible with modern Node.js versions (e.g., Node.js 14+), Express.js (v4+), and Connect.js. It relies on deprecated APIs and patterns, leading to runtime errors or unexpected behavior.","severity":"breaking","affected_versions":">=0.1.7"},{"fix":"If used in an older CommonJS environment, stick to `require()`. For modern projects using ESM, this package is fundamentally incompatible and requires migration to an ESM-compatible alternative.","message":"The package is CommonJS-only and does not provide ES Module support. Attempting to `import` it will result in an `ERR_REQUIRE_ESM` or similar error in ES Module contexts.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Always ensure `res.status(200).send('OK')` or a similar response mechanism is called within the `complete` callback to properly terminate the HTTP transaction.","message":"The `complete` callback function in the middleware requires manual handling of the HTTP response (`res`). If you implement `complete`, you must explicitly send a response (e.g., `res.send()`, `res.end()`, `res.status().send()`); otherwise, the client connection may hang.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Discontinue use of this package immediately in any production or security-sensitive environment. Replace it with a currently maintained and regularly updated tus server implementation.","message":"Security vulnerabilities are highly probable due to the lack of maintenance. The package has not received updates for almost a decade, making it vulnerable to known and unknown exploits related to file uploads, path traversal, or denial of service.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure `const tus = require('tus');` is correct and `tus.createServer` is being invoked with valid options, returning a middleware function.","cause":"This usually happens when `tus.createServer` is not called or returns undefined, often due to an incorrect `require('tus')` statement or a corrupt installation.","error":"TypeError: app.use() requires middleware functions but got a undefined"},{"fix":"Run `npm install tus` in your project directory to install the package.","cause":"The package `tus` is not installed or not resolvable in the current project.","error":"Error: Cannot find module 'tus'"},{"fix":"Update your Express response handling in the `complete` callback to `res.status(200).send('OK')` or `res.sendStatus(200)` for simple status codes.","cause":"The provided example or existing code uses an old Express API for `res.send(status)`, which is deprecated in modern Express.js versions.","error":"DeprecationWarning: res.send(status) is deprecated"},{"fix":"Ensure the user running the Node.js application has read and write permissions to the configured upload `directory`.","cause":"The Node.js process does not have write permissions to the specified `directory` for file uploads.","error":"Error: EACCES: permission denied, open '/path/to/uploads/temp_file'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}