Installation
Core is framework-agnostic. Import the separate Next.js and RSocket entry points only when you use those features.
npm install
bash
npm i @byeolnaerim/typed-rx-http rxjsCore (framework-independent)
ts
import {
createHttpClient,
createHeaderStore,
createCsrCache,
createSessionAuth,
HttpResponseError,
isHttpResponseError,
type ServiceArguments,
type CacheForService,
} from "@byeolnaerim/typed-rx-http";Standard HTTP requests, NDJSON streaming, HeaderStore, session auth, and CSR cache are included in the default entry point. Core can be used without Next.js.
Next.js adapter (optional)
ts
import {
callApiSsrCache,
redirectToUnauthorizedOnServer401,
} from "@byeolnaerim/typed-rx-http/next";RSocket adapter (optional)
Install the peer packages only in projects that use RSocket.
bash
npm i rsocket-core rsocket-types rsocket-websocket-clientts
import { createRSocketApi } from "@byeolnaerim/typed-rx-http/rsocket";
const api = createRSocketApi("ws://localhost:7000/rsocket", jwt);
api.mono<User>("user.findById", { id: 1 }).subscribe((user) => {
console.log(user);
});
api.stream<Notification>("notification.stream").subscribe((notification) => {
console.log(notification);
});OpenAPI/Swagger Auto Node Script (optional)
In addition to the runtime HTTP client, the package includes a Node script that generates TypeScript types and service files from OpenAPI/Swagger JSON. This feature is optional and is not required to use Core, /next, or /rsocket.
ts
import {
connectToSwaggerEventStream,
generateSwaggerFromHttp,
generateSwaggerFromFile,
} from "@byeolnaerim/typed-rx-http/auto-node-script/openapi";