@opra/client
v1.28.5
Published
Opra Client package
Downloads
3,086
Readme
@opra/client
Type-safe HTTP client for the OPRA framework
🌐 Documentation · 🚀 Getting Started · 📦 Packages · 💬 Issues
Type-safe HTTP client for the OPRA framework. Built from your API document — no manual client code required.
Features
OpraHttpClient— Ready-to-use HTTP client backed by the Fetch APIHttpClientBase— Extensible base class for custom client implementationsFetchBackend— Configurable fetch backend with default headers and options- Interceptors — Request/response middleware pipeline
- Type-safe requests — All calls are typed from the server API document
Installation
npm install @opra/clientUsage
import { OpraHttpClient } from '@opra/client';
const client = new OpraHttpClient('https://api.example.com', {
document: apiDocument,
});
const body = await client.request('users/findMany').getBody();With interceptors
const client = new OpraHttpClient(baseUrl, {
document: apiDocument,
interceptors: [
async (req, next) => {
req.headers.set('Authorization', `Bearer ${token}`);
return next(req);
},
],
});Node Compatibility
- node >= 20.x
License
Available under MIT license.
