@richardmcquiston01/chat-and-react-adapters
v0.5.0
Published
Optional input, output, and error-log adapters (webhook, WebSocket, MongoDB, MySQL, EventEmitter) for chat-and-react.
Maintainers
Readme
@richardmcquiston01/chat-and-react-adapters
Optional input, output, and error-log adapters for chat-and-react. Use alongside @richardmcquiston01/chat-and-react-core or the @richardmcquiston01/chat-and-react web component.
Installation
npm install @richardmcquiston01/chat-and-react-adaptersmongodb and mysql2 are optional peer dependencies — install whichever ones you need.
Output adapters
EventEmitterOutputAdapter — emit events on a Node.js EventEmitter:
import { EventEmitter } from "node:events";
import { EventEmitterOutputAdapter } from "@richardmcquiston01/chat-and-react-adapters";
const emitter = new EventEmitter();
const adapter = new EventEmitterOutputAdapter(emitter);WebhookOutputAdapter — POST each event to a webhook URL (fire-and-forget):
import { WebhookOutputAdapter } from "@richardmcquiston01/chat-and-react-adapters";
const adapter = new WebhookOutputAdapter("https://api.example.com/events", {
headers: { Authorization: "Bearer my-token" },
});WebSocketOutputAdapter — send events over an open WebSocket (no-ops silently if the socket isn't open).
Error-log adapters
WebhookErrorAdapter— POSTChatErrorobjects to a webhook URLMongoDbErrorAdapter— insertChatErrorobjects into a MongoDB collection
Input adapters
MySqlInputAdapter— static asynccreate()factory; fetches a schema via amysql2-compatible connection and caches itMongoDbInputAdapter— static asynccreate()factory; fetches a schema document from MongoDB and caches it
Full documentation
See the project README for full usage examples for every adapter.
License
Apache 2.0 — see LICENSE.
