inkwire-receiver-core
v0.2.0
Published
Shared TS core (validate, render, sanitize, upsert) for building an Inkwire receiver.
Readme
inkwire-receiver-core
Shared TypeScript core for building an Inkwire receiver: validate the incoming payload, derive SEO metadata, render+sanitize markdown to HTML, and upsert by external_id against a PostStore you provide.
import { handlePost, MemoryStore } from "inkwire-receiver-core";
const store = new MemoryStore(); // or your own PostStore-backed implementation
const { status, body, headers } = await handlePost({
authHeader: req.headers.get("authorization"),
rawBody: await req.json(),
apiKeys: ["your-api-key"],
store,
});This package is the shared logic behind the Express and Next.js reference receivers — see either for a full adapter example, and the protocol spec for the wire contract handlePost implements.
Exports
handlePost(input)— the whole request lifecycle: auth, validation, slugging, sanitization, store upsert.type PostStore— the interface your storage backend must implement (findByExternalId,findBySlug,upsert).type SeoMetadata— effective title, description, image, and indexing values passed toPostStore.upsert.MemoryStore— an in-memoryPostStorefor local dev/testing.renderMarkdown,slugify— the sanitization and slug-generation helpershandlePostuses internally.InkwireError— typed error class mapping to the protocol's error codes.
