Registry / http-networking / shred
library1.1.0-alpha-10jsnpmunverified

Shred is a resource-oriented HTTP client for JavaScript/Node.js that allows declarative definition of API wrappers with support for URL templates, response compression, authorization, and streaming. The current version is 1.1.0-alpha-10 (alpha quality). It is a complete reboot from 1.0.x, not backwards compatible. Key differentiator: declarative resource definition using CoffeeScript/JavaScript objects, focusing on HTTP resource abstraction rather than low-level requests.

npm install shred
INSTALL
IMPORT
SIG · SHRED
S
shred
http-networkingjavascriptv1.1.0-alpha-10
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.

resource
import { resource } from 'shred'
const shred = require('shred');
Default export is not provided; named export 'resource' is the main entry point. ESM only in v1.x.
invoke
import { invoke } from 'shred'
Used for explicit invocation of request functions.
ShredResponse
import type { ShredResponse } from 'shred'
TypeScript users may need to import type for responses.

Defines a GitHub API client using shred's resource-oriented approach and performs a simple issue listing request.

const { resource } = require('shred'); const github = resource('https://api.github.com/', { repos: (resource) => resource('repos/{owner}/{repo}/', { issues: (resource) => resource('issues', { list: { method: 'get', headers: { accept: 'application/vnd.github.v3.raw+json' }, expect: 200 } }) }) }); async function main() { try { const { data } = await github.repos({ owner: 'user', repo: 'repo' }).issues.list(); console.log(data); } catch (error) { console.error(error); } } main();
Debug
Known issues
breakingShred 1.0.x is a complete reboot and not backwards compatible with earlier versions (0.x).
fix
Update code to use new resource-based declarative API; see README for migration guide.
affects: >=1.0.0 <2.0.0
deprecatedShred 1.x is alpha quality; API may change before stable release.
fix
Pin to specific version and test thoroughly when upgrading.
affects: >=1.0.0 <2.0.0
gotchaResponse 'data' is a promise that resolves when streaming finishes; must be awaited.
fix
Use await on response.data to get parsed JSON or string body.
affects: >=1.0.0
gotchaURL templates use colon syntax (e.g., '/:id') not '{id}' pattern in some versions; verify README.
fix
Use library's documented template syntax.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'data')
Forgetting to await the response object before accessing .data.
fix
const { data } = await request();
Error: Unexpected token o in JSON at position 1
Non-JSON response parsed as JSON because content-type indicated JSON but body is not valid JSON.
fix
Check server response or set headers appropriately.
Upgrade
Version history
1.1.0-alpha-10latest on npm
Audit
Dependencies
coffee-scriptoptionalCore library written in CoffeeScript; may require it for development or interpretation
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
shred — npm install shred · libregistry