Registry / devops / zhi-github-middleware

zhi-github-middleware

JSON →
library0.5.4jsnpmunverified

A middleware library for interacting with the GitHub API. Version 0.5.4 is the current stable release. It provides a CommonGithubClient class that wraps @octokit/core for common GitHub operations like fetching page tree nodes. The package includes TypeScript definitions and uses js-base64 for encoding. Release cadence is irregular. Key differentiator: simplifies GitHub API calls for blog workflows (e.g., Hexo) with a lightweight abstraction.

npm install zhi-github-middleware
INSTALL
IMPORT
SIG · ZHI-GITHUB-MIDDLEW
Z
zhi-github-middleware
devopsjavascriptv0.5.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CommonGithubClient
import { CommonGithubClient } from 'zhi-github-middleware';
import CommonGithubClient from 'zhi-github-middleware';
The export is a named export, not default. CommonJS: const { CommonGithubClient } = require('zhi-github-middleware');
GithubConfig
import { GithubConfig } from 'zhi-github-middleware';
const GithubConfig = require('zhi-github-middleware').GithubConfig;
Also a named export. In TypeScript, you may need to import the type separately if using isolatedModules.
IGithubConfig
import type { IGithubConfig } from 'zhi-github-middleware';
import { IGithubConfig } from 'zhi-github-middleware';
IGithubConfig is a TypeScript interface, should be imported with `type` to avoid runtime errors.

Create a GithubConfig with owner, repo, and token, then instantiate CommonGithubClient to fetch a page tree node.

import { CommonGithubClient, GithubConfig } from 'zhi-github-middleware'; const config = new GithubConfig('owner', 'repo', 'token'); const client = new CommonGithubClient(config); async function main() { const result = await client.getGithubPageTreeNode('path/to/file.md'); console.log(result); } main().catch(console.error);
Debug
Known issues
breakingClass names and API may change between patch versions without notice
fix
Pin to exact version and test before upgrading.
affects: <1.0.0
gotchaPassing empty token string causes silent authentication failure
fix
Always provide a valid GitHub token. For public repos, use a minimal token or PAT.
affects: >=0.0.0
deprecatedgetGithubPageTreeNode might be renamed in future versions
fix
Check the changelog or use the latest method name.
affects: >=0.5.0
Errors
Common errors & fixes
TypeError: GithubConfig is not a constructor
Importing GithubConfig as a default export instead of named export.
fix
Use import { GithubConfig } from 'zhi-github-middleware';
Cannot find module 'zhi-github-middleware' or its corresponding type declarations.
Missing TypeScript type declarations or incorrect module resolution.
fix
Ensure tsconfig.json has 'moduleResolution': 'node' and install the package with npm.
Upgrade
Version history
0.5.4latest on npm
Audit
Dependencies
@octokit/corerequiredCore GitHub API client for all requests
js-base64requiredBase64 encoding for file contents
Agent activity
20 hits · last 30 days
node
18
Resources
zhi-github-middleware — npm install zhi-github-middleware · libregistry