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

@capyclaw/service-host

v0.1.2

Published

DSH 公共服务宿主插件:统一 HTTP 路由、健康检查、指标、单实例锁、端口复用与静态资源,向插件提供 ctx.serviceHost。

Readme

@capyclaw/service-host

DSH 公共服务宿主插件。功能插件通过 ctx.serviceHost 获得统一的 HTTP 运行时,不必再为每个插件复制 relay/路由/健康/指标/锁/静态资源代码。

使用

export const inject = ['serviceHost']

export function apply(ctx, config) {
  const app = ctx.serviceHost.createApp({
    id: 'my-plugin',
    title: 'My Plugin',
    version: '1.0.0',
    contractVersion: '1.0.0',
    health: () => ({ ready: true }),
    metrics: () => [['my_items', 3]],
  })
  app.use(myRoutes)
  await app.listen({
    port: config.port,
    hostDir: config.hostDir,
    strictPort: config.strictPort,
  })
  return () => app.close()
}

独立运行:

import { createServiceApp } from 'dsh-service-host/src'
const app = createServiceApp({ id: 'my-plugin' })
app.get('/ping', (req, res) => res.end('pong'))
const info = await app.listen({ port: 39500 })

嵌入 DSH Web:

await app.listen({ webServer: ctx.webServer, basePath: '/plugins/my-plugin' })

共享宿主(多插件一个端口)

const host = ctx.serviceHost.createSharedHost({ id: 'dsh-app' })
host.mount('/plugins/ppt', pptApp)
host.mount('/plugins/canvas', canvasApp)
await host.listen({ port: 3080 })

子 app 仍由 createServiceApp() 创建;共享宿主只做前缀分发和统一生命周期。

提供什么

  • createServiceApp(options):路由、静态、健康、指标、生命周期
  • createServiceHost(config):插件侧工厂
  • 标准 /healthz:{ ok, service, name, version, contractVersion, pid, port, uptimeSec, ...业务字段 }
  • 标准 /metrics:<slug>_up、<slug>_uptime_seconds、<slug>_port + 业务指标
  • standalone:端口扫描、strictPort、复用探测、单实例锁、discovery 文件、优雅关闭
  • embedded:注册到 ctx.webServer 的 <basePath> 前缀

边界

  • 不拥有业务状态;状态用 @capyclaw/state-service
  • 不拥有资产;资产用 dsh-asset-service
  • 不拥有编辑器;编辑器用 dsh-editor-host