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

@mithril-inspector/server

v0.3.2

Published

Open-in-editor middleware for Mithril Inspector (VS Code / VS Code Insiders / custom editors).

Downloads

1,065

Readme

@mithril-inspector/server

Open-in-editor middleware for Mithril Inspector. Framework-neutral: handleInspectorRequest takes and returns plain data, and createInspectorMiddleware adapts it to a Connect-compatible handler (what Vite's and webpack's dev servers use). No bundler dependency itself (ADR-004) — every adapter (vite, rollup, esbuild, webpack) consumes it.

What it does

Serves one endpoint, POST /__mithril-inspector/open-in-editor, that takes a { file, line, column } body and launches the configured editor at that location. Everything else passes through untouched.

Security:

  • Path traversal prevention — the requested file is resolved and checked against root (and any projectRoots for monorepos) before anything is launched; a path escaping every configured root is rejected.
  • Command-injection prevention — the editor is launched via execFile-style argv arrays (never a shell string), so file/line/ column can never be interpreted as shell syntax.
  • Bounded request bodies — streamed and capped at maxBodyBytes (DEFAULT_MAX_BODY_BYTES, 16 KiB) before the handler ever sees them.

Usage

import { createInspectorMiddleware } from "@mithril-inspector/server"

app.use(
  createInspectorMiddleware({
    root: projectRoot,
    editor: "code", // alias | { command, args } | undefined (env-var fallback)
    projectRoots: [monorepoPackageRoot], // optional, for monorepos
    pathMappings: [{ from: "/workspace", to: "/Users/me/project" }], // optional, remote/container dev
  }),
)

Supported editor aliases: code, code-insiders, cursor, windsurf, webstorm, plus a custom { command, args: (location) => string[] } shape for anything else. With no editor option, resolveEditor checks MITHRIL_INSPECTOR_EDITOR, LAUNCH_EDITOR, VISUAL, then EDITOR in that order, and finally falls back to "code" (VS Code) so the endpoint works out of the box — it never reports EDITOR_NOT_AVAILABLE on its own.

Standalone server

Bundlers with no development-server hook of their own (e.g. @mithril-inspector/rollup) can start a small standalone HTTP server serving just this endpoint:

import { startInspectorServer } from "@mithril-inspector/server"

const handle = await startInspectorServer({ root: projectRoot, editor: "code" })
console.log(handle.url) // http://127.0.0.1:<port>
// later: await handle.close()

Binds to 127.0.0.1 by default (never a network-reachable host) and adds no CORS headers, so a page must be same-origin to call it — pair it with a reverse proxy, or mount createInspectorMiddleware directly in a dev server you already run, if the app is served from a different origin/port.

Lower-level pieces

handleInspectorRequest (bundler-neutral request/response, for adapters that aren't Connect), resolveEditor, applyPathMappings, resolveRequestedFile, parseEditorRequestBody, and spawnEditorProcess (injectable — tests pass a stub launcher so no test run ever spawns a real editor process, see tests/browser/README.md) are all exported individually for adapters that need finer control than the middleware wrapper.