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

@heyputer/worker-types

v1.0.0

Published

TypeScript type definitions for the Puter Workers runtime (router, globals, handler events, env bindings).

Downloads

21

Readme

@heyputer/worker-types

TypeScript type definitions for the Puter Workers runtime.

Adds type-checking and autocomplete for the globals the runtime injects into every worker — router, me, my, myself, puter_auth, puter_endpoint — plus typed route handlers with automatic params inference from path literals.

Install

npm install --save-dev @heyputer/worker-types

Setup

The recommended convention is to name worker files *.worker.js or *.worker.ts and opt them in to the global types either per-file or via a worker-only tsconfig. Globals don't leak into the rest of your project this way.

File-scoped (works for any project)

Add a triple-slash reference at the top of each *.worker.js / *.worker.ts file:

/// <reference types="@heyputer/worker-types" />

router.get('/api/hello', ({ request }) => {
    return { msg: 'hello' };
});

This is the line that the New > Worker action in the Puter GUI now adds automatically (the file is created as New Worker.worker.js).

Project-wide for worker files only

If you have many workers and don't want to repeat the directive, add a worker-only tsconfig.workers.json that targets the *.worker.ts files:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "types": ["@heyputer/worker-types"]
  },
  "include": ["**/*.worker.ts"]
}

Then exclude those same files from your main tsconfig.json so the worker globals don't bleed into the rest of your code:

{
  "exclude": ["**/*.worker.ts"]
}

Run both with tsc -p tsconfig.json && tsc -p tsconfig.workers.json, or use TypeScript project references.

Named imports (optional)

For users who prefer being explicit, the same types are exported by name. Importing anything pulls the globals into that file, so you don't also need the triple-slash reference:

import type { Handler, Router, WorkerEvent } from '@heyputer/worker-types';

const getPost: Handler<{ id: string }> = ({ params }) => ({ id: params.id });
router.get('/posts/:id', getPost);

What you get

| Global | Type | Description | |---|---|---| | router | Router | Register handlers via get/post/put/delete/options/custom. | | me | { puter: Puter } | Deployer's Puter context (FS, KV, AI, auth, etc). | | my, myself | { puter: Puter } | Aliases for me. | | puter_auth | string | Deployer's auth token (Cloudflare secret binding). | | puter_endpoint | string | Puter API endpoint. |

The event object passed to a handler exposes:

  • request — standard Request
  • params — route params, inferred from the path literal ('/posts/:id' -> { id: string })
  • user / requestor — caller's Puter context, present only when the worker is invoked with a puter-auth header (e.g. via puter.workers.exec())

Handlers can return a Response, a string, a Blob/ArrayBuffer/Uint8Array/ReadableStream, or any JSON-serialisable value — the router wraps it for you.

Param inference

Path literals are parsed at the type level, so destructuring params in a handler gives you exact keys:

router.get('/posts/:postId/comments/:commentId', ({ params }) => {
    params.postId;    // string
    params.commentId; // string
    // @ts-expect-error - 'foo' is not a param
    params.foo;
});

router.get('/files/*path', ({ params }) => {
    params.path; // string (wildcard captures the remainder)
});