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

@bibliotype/adapter-http

v26.10.25-rc.1

Published

远端存储适配器(REST:文档 + 资产)- bibliotype 存储适配包

Readme

@bibliotype/adapter-http

远端存储适配器:实现 core 的 StorageAdapter(文档)与 AssetStore(资产),基于 REST 契约。

安装

pnpm add @bibliotype/adapter-http @bibliotype/core

快速上手

import { createHttpAdapter } from '@bibliotype/adapter-http';

const adapter = createHttpAdapter({
  baseUrl: 'https://api.example.com/books',
  headers: { Authorization: 'Bearer <token>' },
});

await adapter.save('book-1', document, { updatedAt: Date.now() });
const loaded = await adapter.load('book-1');

// 资产(图片 / 字体 / 音频)
await adapter.putAsset('cover', { mediaType: 'image/png', data: bytes });

端点契约

| 方法 | 路径 | 语义 | | --- | --- | --- | | PUT | /documents/:id | body { document, updatedAt } | | GET | /documents/:id | → { document };404 未命中 | | GET | /documents | → { documents: DocumentSummary[] } | | DELETE | /documents/:id | 2xx / 404 | | DELETE | /documents | 清空 | | PUT | /assets/:id | 原始字节,Content-Type 为 MIME | | GET | /assets/:id | 原始字节(靠响应 Content-Type 还原 mediaType) | | GET | /assets | → { assets: AssetRef[] } | | DELETE | /assets/:id | 2xx / 404 |

API 概览

| 分组 | 导出 | | --- | --- | | 适配器 | createHttpAdapter / HttpAdapterError、HttpAdapterOptions | | 端口类型 | FetchLike / HttpRequestInit / HttpResponseLike / HttpHeadersLike | | 工具 | resolveGlobalFetch |

约定

  • 除 404 外,非 2xx 一律抛 HttpAdapterError(含 status / path),不静默吞错;
  • 网络异常包装为 status = 0;
  • 读到的 document 不是合法 IR 时抛错,不返回脏数据;
  • updatedAt 由 SaveOptions 注入(缺省取 clock),保证可测与可回溯;
  • 资产哈希由 core 的 toAssetRef 统一计算(FNV-1a,可用于去重)。

相关