npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-tus-uploader

v0.0.1

Published

Angular service for resumable file uploads using the tus protocol via tus-js-client.

Readme

ngx-tus-uploader

An Angular service for resumable file uploads using the tus protocol 1.0.0 via tus-js-client.
Supports progress tracking, authentication headers, retry policies, and additional metadata.


Features

  • 📦 Resumable uploads with chunked transfer (default: 5 MB chunks)
  • 🔄 Automatic retries with configurable backoff
  • 📊 Progress reporting (bytesUploaded, bytesTotal, percentage)
  • 🔑 Authentication via custom headers (e.g. Authorization: Bearer …)
  • 📝 Custom upload metadata (guid, member, filepath)
  • ⏸ Cancel or pause an ongoing upload

Installation

npm install ngx-tus-uploader tus-js-client

Requires Angular 13+ (service is providedIn: 'root').


Usage

1. Inject the service and start an upload

import { Component } from '@angular/core';
import { NgxTusUploaderService, UploadProgress } from 'ngx-tus-uploader';

@Component({
  selector: 'app-upload',
  templateUrl: './upload.component.html',
})
export class UploadComponent {
  selectedFile: File | null = null;
  progress: UploadProgress | null = null;
  isUploading = false;
  message = '';
  messageType: 'success' | 'error' | '' = '';

  constructor(private tus: NgxTusUploaderService) {}

  onFileSelected(ev: Event) {
    const input = ev.target as HTMLInputElement;
    this.selectedFile = input.files?.[0] ?? null;
  }

  startUpload() {
    if (!this.selectedFile) return;
    this.isUploading = true;

    const endpoint = 'https://your-server/upload';
    const token = '<JWT>';

    this.tus.startUpload(
      this.selectedFile,
      endpoint,
      { scheme: 'Bearer', token }, // The TUS server used the token in headers
      { guid: 'abc123', member: 1 },// (optional header if you server use extra header)
      (p: UploadProgress) => (this.progress = p),
      () => {
        this.message = 'Upload completed!';
        this.messageType = 'success';
        this.isUploading = false;
      },
      (err: Error) => {
        this.message = err.message;
        this.messageType = 'error';
        this.isUploading = false;
      }
    );
  }

  cancelUpload() {
    this.tus.abortUpload();
    this.isUploading = false;
    this.message = 'Upload canceled';
    this.messageType = 'error';
  }
}

2. Example template

<input type="file" (change)="onFileSelected($event)" />

<button (click)="startUpload()" [disabled]="!selectedFile || isUploading">
  {{ isUploading ? 'Uploading…' : 'Upload' }}
</button>

<button *ngIf="isUploading" (click)="cancelUpload()">
  Cancel
</button>

<div *ngIf="progress">
  {{ progress.percentage | number: '1.0-0' }}%
</div>

<div *ngIf="message" [class]="messageType">
  {{ message }}
</div>

API

startUpload(file, endpoint, auth, extra, onProgress, onSuccess, onError)

  • file: File object from <input type="file">.
  • endpoint: TUS upload endpoint URL.
  • auth (optional): Authorization header config:
    • { raw: 'Bearer eyJ…' } or { scheme: 'Bearer', token: 'eyJ…' }
  • extra: Additional metadata sent as Upload-Metadata:
    • guid: string
    • member?: string|number
    • filePath?: string (sent as filepath)
  • onProgress: (progress: { bytesUploaded, bytesTotal, percentage }) => void
  • onSuccess: () => void
  • onError: (error: Error) => void

abortUpload()

Cancels or pauses the current upload.


Server Requirements

Your TUS server must:

  • Support POST, HEAD, PATCH, OPTIONS (and optionally DELETE)
  • Return Tus-Resumable: 1.0.0 in all responses
  • Return Upload-Offset, Upload-Length, and Upload-Metadata in HEAD responses
  • Correctly handle chunked uploads (PATCH requests)
  • Allow CORS for:
    • Methods: POST, HEAD, PATCH, OPTIONS, DELETE
    • Headers: Authorization, Tus-Resumable, Upload-Offset, Upload-Length, Upload-Metadata, Content-Type
    • Exposed headers: Location, Tus-Resumable, Upload-Offset, Upload-Length, Upload-Metadata

Best Practices

  • Ensure your server persists upload state until completion
  • Test CORS preflight (OPTIONS) before expecting uploads to work in browsers

License

MIT