@dianemo/plugin-printnode
v1.0.0
Published
PrintNode plugin — remote print job dispatch
Maintainers
Readme
@dianemo/plugin-printnode
PrintNode plugin — remote print job dispatch
A plugin for dianemo, which distributes one API rate limit across every process that draws on it.
npm install @dianemo/core @dianemo/backend-redis @dianemo/plugin-printnode ioredisSetup
import RequestHandler, { buildClientName } from "@dianemo/core";
import { redisBackend } from "@dianemo/backend-redis";
import printNode from "@dianemo/plugin-printnode";
import { Redis } from "ioredis";
const handler = new RequestHandler({
key: process.env.DIANEMO_KEY!,
backend: redisBackend(new Redis(process.env.REDIS_URL!)),
});
export const requests = handler.use(printNode);
// Credentials are encrypted into the backend, so every process pointed at this
// Redis rebuilds the same client and draws on one shared budget.
await handler.addTemplateClient("printNode", {
instanceId: "main",
baseUrl: "https://api.printnode.com",
token: process.env.PRINTNODE_API_KEY!,
});
// "printNode:_:main" — <template>:<organizationId | "_">:<instanceId>
const account = buildClientName("printNode", { instanceId: "main" });
const printers = await requests.printNode.getAllPrinters(account);Register another account by calling addTemplateClient again with a different instanceId. Pass
organizationId alongside it in a multi-tenant deployment: it becomes the second segment of the
client name, keeping each tenant's credentials and budget separate.
API notes. The rate-limit evidence behind this package's calibration, the wire quirks
it works around, and the questions still open are in
docs/printnode-api.md — it ships with the package.
See dianemo-plugins for the full catalogue.
