spaghettix
v2.1.1
Published
A lightweight, TypeScript-friendly HTTP client for a hyper-custom taxonomy WordPress-powered API. Built on **axios** and **rxjs**, CatClient wraps common WP REST endpoints—Tags, Categories, Access Levels, Portfolios, Products, and Product Content—into e
Readme
Spaghettix
A lightweight, TypeScript-friendly HTTP client for a hyper-custom taxonomy WordPress-powered API.
Built on axios and rxjs, CatClient wraps common WP REST endpoints—Tags, Categories, Access Levels, Portfolios, Products, and Product Content—into easy-to-use promise and Observable methods.
🚀 Features
- Promise & Observable APIs out of the box
- Simple Basic Auth helper
- Full TypeScript typings for all endpoints
- CRUD support for ProductContent (posts)
- Extensible—drop in your own axios instance if you need custom interceptors
📦 Installation
npm install spaghettix
# or
yarn add spaghettix🔧 Usage
- Basic setup
import { Spaghettix } from "spaghettix";
const client = new Spaghettix({
baseUrl: "https://example.com",
authorization: Spaghettix.encode("username:password"), // base64 Basic Auth
});
// Promise style
(async () => {
const tags = await client.getWPTags({ params: { all: true } });
console.log("Tags:", tags);
})();- Observable style
import { Spaghettix } from "spaghettix";
const client = new Spaghettix({ /* … */ });
client.getWPCategories$({ params: { all: true } })
.subscribe({
next: cats => console.log("Categories:", cats),
error: err => console.error("API error:", err),
});🔍 Filtering by ID or Slug
You can filter results using the include or slug parameters:
// Fetch a single item by ID
const category = await client.getWPCategories({ params: { include: 123 } });
// Fetch multiple items by ID
const tags = await client.getWPTags({ params: { include: [1, 2, 3] } });
// Fetch by slug
const products = await client.getWPProducts({ params: { slug: 'my-product' } });