floosher
v1.0.3
Published
Official Floosher SDK — render PDF/PNG jobs and verify webhooks
Downloads
23
Readme
floosher
Official Node.js/TypeScript SDK for Floosher — convert HTML/CSS/Handlebars templates into PDFs and PNGs via a simple API.
Install
npm install floosherUsage
import { FloosherApiClient } from "floosher";
const client = new FloosherApiClient({
token: process.env.FLOOSHER_API_KEY,
});
const job = await client.render.pdf({
templateId: "your-template-id",
data: { name: "Fahama" },
webhookUrl: "https://yourapp.com/hooks/floosher",
});
console.log(job.jobId);
const status = await client.jobs.get(job.jobId);
console.log(status.status, status.outputUrl);Verifying webhooks
import { constructEvent, SignatureVerificationError } from "floosher";
import express from "express";
const app = express();
app.post("/hooks/floosher", express.raw({ type: "application/json" }), (req, res) => {
try {
const event = constructEvent(
req.body,
req.headers["x-floosher-signature"] as string,
process.env.FLOOSHER_WEBHOOK_SECRET!
);
console.log(`Job ${event.jobId} is now ${event.status}`);
res.sendStatus(200);
} catch (err) {
if (err instanceof SignatureVerificationError) {
return res.status(400).send("Invalid signature");
}
throw err;
}
});Important: constructEvent needs the raw request body — use express.raw({ type: "application/json" }) on this route.
License
MIT
