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

@utsuk/file-upload-server

v0.1.0

Published

Express middleware for presigned S3 PUT/GET URLs (file upload accelerator server).

Downloads

133

Readme

@utsuk/file-upload-server

Express middleware that exposes:

  • POST /upload/presign → presigned PUT URL for browser → S3 upload
  • GET /upload/url?key=... → presigned GET URL for download/preview

Install (consumer server)

npm install @utsuk/file-upload-server

Peer dependency:

  • express >= 4

Mounting (Express)

Mount after express.json() so the presign route can read JSON bodies.

import express from "express";
import { createFileUploadMiddleware } from "@utsuk/file-upload-server";

const app = express();
app.use(express.json());

app.use(
  createFileUploadMiddleware({
    s3: {
      bucket: process.env.S3_BUCKET!,
      access_key_id: process.env.S3_ACCESS_KEY_ID!,
      secret_access_key: process.env.S3_SECRET_ACCESS_KEY!,
      region: process.env.S3_REGION ?? "eu-west-2", // R2 uses "auto"
      endpoint: process.env.S3_ENDPOINT,            // omit for AWS
      force_path_style: process.env.S3_FORCE_PATH_STYLE === "true",
      disable_request_checksum_calculation: process.env.S3_DISABLE_CHECKSUM === "true",
      key_prefix: process.env.S3_KEY_PREFIX ?? "uploads",
      presigned_upload_ttl: 300,
      presigned_download_ttl: 3600,
      session_token: process.env.S3_SESSION_TOKEN,  // optional
    },
    accepted_file_types: [".pdf", ".jpg", ".png"],
    max_file_size: 10 * 1024 * 1024,
    cors_origins: process.env.CORS_ORIGINS?.split(",") ?? ["http://localhost:3000"],
    upload_route: "/upload/presign",
    download_route: "/upload/url",
    rate_limit: { window_ms: 60_000, max_requests: 30 },
    auth: { mode: "header", header_name: "authorization" }, // or custom/none
    strict_filename_validation: true,
  })
);

Important contract details

  • size_bytes is mandatory on the presign request body (400 if missing/<=0).
  • The presigned PUT binds Content-Type into the signature. The response includes:
    • headers: { "Content-Type": filetype }
    • the client must send those headers verbatim on PUT.
  • Download URL generation validates the key is under key_prefix and rejects traversal patterns.
  • Rate limiting uses express-rate-limit by default.

Local development (this monorepo)

From utsuk-file-upload/:

corepack pnpm nx build file-upload-server
corepack pnpm nx test file-upload-server
corepack pnpm nx typecheck file-upload-server