Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tus/server

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tus/server - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0-beta.6

5

dist/handlers/BaseHandler.js

@@ -21,3 +21,6 @@ "use strict";

write(res, status, headers = {}, body = '') {
headers = status === 204 ? headers : { ...headers, 'Content-Length': body.length };
if (status !== 204) {
// @ts-expect-error not explicitly typed but possible
headers['Content-Length'] = Buffer.byteLength(body, 'utf8');
}
res.writeHead(status, headers);

@@ -24,0 +27,0 @@ res.write(body);

@@ -43,4 +43,5 @@ "use strict";

if (file.metadata !== undefined) {
// If the size of the upload is known, the Server MUST include
// the Upload-Length header in the response.
// If an upload contains additional metadata, responses to HEAD
// requests MUST include the Upload-Metadata header and its value
// as specified by the Client during the creation.
res.setHeader('Upload-Metadata', models_1.Metadata.stringify(file.metadata));

@@ -47,0 +48,0 @@ }

3

dist/handlers/PostHandler.d.ts

@@ -6,5 +6,4 @@ /// <reference types="node" />

import type { DataStore } from '../models';
import type { SetRequired } from 'type-fest';
export declare class PostHandler extends BaseHandler {
options: SetRequired<ServerOptions, 'namingFunction'>;
options: Required<Pick<ServerOptions, 'namingFunction'>> & Omit<ServerOptions, 'namingFunction'>;
constructor(store: DataStore, options: ServerOptions);

@@ -11,0 +10,0 @@ /**

@@ -23,2 +23,3 @@ /// <reference types="node" />

_writeChunk(chunk: Buffer): Promise<void>;
_handleError(): Promise<void>;
_finishChunk(): Promise<void>;

@@ -25,0 +26,0 @@ _newChunk(): Promise<void>;

@@ -25,3 +25,3 @@ "use strict";

this.part = 0;
this.on('error', this._finishChunk.bind(this));
this.on('error', this._handleError.bind(this));
}

@@ -73,2 +73,13 @@ async _write(chunk, _, callback) {

}
async _handleError() {
// If there was an error, we want to stop allowing to write on disk as we cannot advance further.
// At this point the chunk might be incomplete advancing further might cause data loss.
// some scenarios where this might happen is if the disk is full or if we abort the stream midway.
if (this.fileHandle === null) {
return;
}
await this.fileHandle.close();
this.currentChunkPath = null;
this.fileHandle = null;
}
async _finishChunk() {

@@ -75,0 +86,0 @@ if (this.fileHandle === null) {

{
"$schema": "https://json.schemastore.org/package.json",
"name": "@tus/server",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.6",
"description": "Tus resumable upload protocol in Node.js",

@@ -37,7 +37,6 @@ "main": "dist/index.js",

"should": "^13.2.3",
"sinon": "^15.0.0",
"sinon": "^15.0.4",
"supertest": "^6.3.2",
"ts-node": "^10.9.1",
"tsconfig": "*",
"type-fest": "^3.1.0",
"typescript": "latest"

@@ -44,0 +43,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc